Skip to content

Glue streaming job fails with JsonParseException when using startingPosition with timestamp for Kinesis source

0

Hi everyone,

I’m running an AWS Glue 4.0 streaming job locally with a Kinesis data stream source. I’m encountering the error shown below, and would like to confirm the correct way to specify a timestamp when using Kinesis as a Glue streaming source. Any suggestions or guidance would be greatly appreciated. Thanks!

Environment: Container image: amazon/aws-glue-streaming-libs:glue_streaming_libs_4.0.0_image_01-arm64 Glue version: 4.0 Spark / PySpark: 3.3

Code snippet: options = { "typeOfData": "kinesis", "streamARN": self.stream_arn, "classification": "json", "startingPosition": "2025-09-01T00:00:00-04:00", # ISO-8601 timestamp "inferSchema": "true", "addRecordTimestamp": "true", "maxFetchTimeInMs": self.stream_max_fetch_time_in_ms }

Error: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('-' (code 45)): Expected space separating root-level values at [Source: (String)"2025-09-01T00:00:00-04:00"; line: 1, column: 6]

asked a year ago198 views

2 Answers
0

Based on your error, it appears you're encountering an issue with the format of the timestamp in the startingPosition parameter for your AWS Glue 4.0 streaming job with a Kinesis data stream source.

For AWS Glue version 4.0 or later, you can indeed use a timestamp string in UTC format for the startingPosition parameter. The supported format is yyyy-mm-ddTHH:MM:SSZ where Z represents a UTC timezone offset with a +/-.

Your timestamp format 2025-09-01T00:00:00-04:00 appears to be correctly formatted according to the ISO-8601 standard with the timezone offset. However, the JsonParseException suggests that the system is trying to parse the timestamp string as a JSON value, which is causing the error.

Try these approaches to resolve the issue:

  1. Make sure you're using AWS Glue version 4.0 or later, which you've confirmed you are.

  2. Try using quotes around your timestamp value in the options dictionary:

"startingPosition": "'2025-09-01T00:00:00-04:00'"
  1. Alternatively, you could try using one of the other valid values for startingPosition such as latest, trim_horizon, or earliest if those meet your requirements.

  2. If you need to use a specific timestamp, you might also try using the startingTimestamp parameter instead of embedding the timestamp directly in the startingPosition parameter.

The error specifically indicates a JSON parsing issue, which suggests the timestamp string is being treated as JSON when it shouldn't be. This could be related to how the options are being passed to the underlying API.
Sources
KinesisStreamingSourceOptions - AWS Glue

answered a year ago

0

Hello,

Based on the error mentioned, you are encountering this issue because the startingPosition option in Glue’s Kinesis connector does not accept a raw timestamp as you are passing.

It only accepts the enums LATEST, TRIM_HORIZON or AT_TIMESTAMP.

When you need to start from a specific point in time you must set,

startingPosition = "AT_TIMESTAMP" startingTimestamp = "<ISO-8601 UTC timestamp>" (for example: "2025-09-01T00:00:00Z")

Currently you have placed timestamp directly into startingPosition, which is why the parser is failing with a JsonParseException.

Next steps, -> Update your glue job options to use "startingPosition": "AT_TIMESTAMP"

->Provide the timestamp separately via "startingTimestamp"

further i recommend using UTC format for the timestamp to avoid timezone parsing issues.

AWS

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.