# 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-01T12:34:56.000Z
to:
2025-01-01T12: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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
# 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-01T12:34:56.000Z
to:
2025-01-01T12: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:
Regression coverage
Added coverage verifying that:
Validation
Full all-target Clippy is currently blocked by unrelated pre-existing warnings in API Gateway/fixture tests.
Fixes #1161