Skip to content

fix(lambda-events): keep sub-second digits when deserializing timestamps - #1199

Open
ranjithguggilla wants to merge 1 commit into
aws:mainfrom
ranjithguggilla:fix/lambda-events-timestamp-subsecond-precision
Open

ranjithguggilla wants to merge 1 commit into
aws:mainfrom
ranjithguggilla:fix/lambda-events-timestamp-subsecond-precision

Conversation

@ranjithguggilla

@ranjithguggilla ranjithguggilla commented Dec 2, 2026 •

Copy link
Copy Markdown

Issue #: none that I could find.

Description of changes:

Two deserializers in lambda-events/src/encodings/time.rs return the wrong time.

MillisecondTimestamp (Firehose / Kafka) goes through whole as f64 / 1000.0, then multiplies the fractional part back and truncates. When that quotient is not exact in binary, you lose a millisecond — e.g. 1507217624349 becomes ...44.348Z instead of ...44.349Z.

SecondTimestamp (Kinesis) parses the digits after the . as an integer and treats that integer as milliseconds, so the place value is lost: 1480641523.47 becomes .047, 1480641523.5 becomes .005. Values this crate wrote with serialize_seconds (like "1480641523.050") also fail to round-trip.

Fix is integer division/modulo for milliseconds, and having normalize_timestamp return the fraction as nanoseconds (right-padded to nine digits) so deserialize_seconds can use it directly. Tests cover the off-by-one millis cases, fractional seconds as numbers and strings, and a SecondTimestamp round trip.

#1198 edits the same functions; happy to rebase or fold this in there if that lands first.

Note: test_serialize_utf8_headers still fails on main under http 1.6.0. That's unrelated and covered by #1200. The encodings::time tests pass (10/10).

By submitting this pull request

  • I confirm that I've ran cargo +nightly fmt.
  • I confirm that I've ran cargo clippy --fix.
  • I confirm that I've made a best effort attempt to update all relevant documentation.
  • I confirm that my contribution is made under the terms of the Apache 2.0 license.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant