Skip to content

Navigation Menu

Sign in
Sign up

Fix SNS timestamp serialization to preserve millisecond precision - #1162

Open
DebadityaHait wants to merge 1 commit into
aws:main from
DebadityaHait:fix-sns-timestamp-roundtrip
Open

Fix SNS timestamp serialization to preserve millisecond precision #1162
DebadityaHait wants to merge 1 commit into
aws:main from
DebadityaHait:fix-sns-timestamp-roundtrip

Conversation

@DebadityaHait

@DebadityaHait DebadityaHait commented Aug 9, 2026

Copy link
Copy Markdown

# Fix SNS timestamp serialization to preserve millisecond precision

Summary

Fix SNS timestamp serialization so whole-second timestamps retain .000 milliseconds.

Chrono omits the fractional component when serializing a DateTime<Utc> that falls exactly on a whole second. For SNS messages, that changes the serialized timestamp from forms such as:

2025年01月01日T12:34:56.000Z

to:

2025年01月01日T12:34:56Z

Because the SNS signature is computed over the original string representation, this changes the SNS string-to-sign and can cause signature verification to fail.

Fix

Serialize the SNS DateTime<Utc> timestamp fields using RFC 3339 with fixed millisecond precision.

This ensures timestamps consistently retain three fractional digits, including .000, while leaving deserialization behavior and the public Rust types unchanged.

The change applies to:

  • SnsMessage
  • SnsSubscriptionMessage
  • SnsMessageObj

Regression coverage

Added coverage verifying that:

  • a timestamp ending in .000Z survives a serialization/deserialization round-trip without losing its millisecond component;
  • existing timestamps with nonzero milliseconds continue to serialize with exactly three fractional digits.

Validation

  • SNS module tests passed: 8 tests
  • cargo fmt --all -- --check passed
  • SNS library Clippy passed with -D warnings

Full all-target Clippy is currently blocked by unrelated pre-existing warnings in API Gateway/fixture tests.

Fixes #1161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

SNS Timestamp doesn't round-trip: serialization drops .000 subseconds, corrupting the signed string-to-sign

1 participant

AltStyle によって変換されたページ (->オリジナル) /