Repository navigation
fix(lambda-events): keep sub-second digits when deserializing timestamps - #1199
Open
ranjithguggilla wants to merge 1 commit into
Open
ranjithguggilla wants to merge 1 commit into
ranjithguggilla wants to merge 1 commit into
Conversation
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue #: none that I could find.
Description of changes:
Two deserializers in
lambda-events/src/encodings/time.rsreturn the wrong time.MillisecondTimestamp(Firehose / Kafka) goes throughwhole 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.1507217624349becomes...44.348Zinstead 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.47becomes.047,1480641523.5becomes.005. Values this crate wrote withserialize_seconds(like"1480641523.050") also fail to round-trip.Fix is integer division/modulo for milliseconds, and having
normalize_timestampreturn the fraction as nanoseconds (right-padded to nine digits) sodeserialize_secondscan use it directly. Tests cover the off-by-one millis cases, fractional seconds as numbers and strings, and aSecondTimestampround trip.#1198 edits the same functions; happy to rebase or fold this in there if that lands first.
Note:
test_serialize_utf8_headersstill fails on main under http 1.6.0. That's unrelated and covered by #1200. Theencodings::timetests pass (10/10).By submitting this pull request
cargo +nightly fmt.cargo clippy --fix.