Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamoDBStreams: DescribeStream response deserialization error #8622

Open
pelegkaz opened this issue Feb 26, 2025 · 0 comments
Open

DynamoDBStreams: DescribeStream response deserialization error #8622

pelegkaz opened this issue Feb 26, 2025 · 0 comments
Assignees
Labels

Comments

@pelegkaz
Copy link

pelegkaz commented Feb 26, 2025

Hi,

I'm using moto as a testcontainer with a golang sdk client in order to mock dynamodbstreams.
When calling DescribeStream, I get error deserializing CreationRequestDateTime.

operation error DynamoDB Streams: DescribeStream, https response error StatusCode: 200, RequestID: eNgJwGwokhpIul3c2cEJcocZj8maXMu83f4kF1d1OnwNs4m4jTBc, deserialization failed, failed to decode response body, expected Date to be a JSON Number, got string instead.

when debugging I see it happens here:

		case "CreationRequestDateTime":
			if value != nil {
				switch jtv := value.(type) {
				case json.Number:
					f64, err := jtv.Float64()
					if err != nil {
						return err
					}
					sv.CreationRequestDateTime = ptr.Time(smithytime.ParseEpochSeconds(f64))
				default:
					return fmt.Errorf("expected Date to be a JSON Number, got %T instead", value)
				}
			}

I think the fix is simply to change the formatting:

@@ -89,7 +90,7 @@ class DynamoDBStreamsBackend(BaseBackend):
                     "ENABLED" if table.latest_stream_label else "DISABLED"
                 ),
                 "StreamViewType": table.stream_specification["StreamViewType"],  # type: ignore[index]
-                "CreationRequestDateTime": table.stream_shard.created_on.isoformat(),  # type: ignore[union-attr]
+                "CreationRequestDateTime": unix_time(table.stream_shard.created_on),  # type: ignore[union-attr]


Thanks!

@bpandola bpandola changed the title DescribeStream API of DynamoDBStreams expects CreationRequestDateTime to be epoch time DynamoDBStreams: DescribeStream response deserialization error Mar 4, 2025
@bpandola bpandola added the bug label Mar 4, 2025
@bpandola bpandola self-assigned this Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants