Fix timestamp parsing to always include milliseconds #2683
Merged
+20
−9
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.
fixes #2671.
See the original slack thread (internal) for more context.
The client expects timestamps to follow the pattern
%Y-%m-%dT%H:%M:%S.%fZ
, but the server was inconsistently returning timestamps without milliseconds when they were zero (e.g. "2024-11-20T20:01:58Z"). This causes the parsing error reported in the issue mentioned above.we're handling this client-side as it's intentional behavior in the API to reduce precision, see this comment (private).
this is fixed by a small refactoring of
parse_datetime()
function and adding a normalization to ensure it has six digits of microseconds by padding with zeros or truncating. This approach handles inputs with or without milliseconds and nanoseconds.cc @ErikKaum