fix: improve ISO datetime parsing#404
Merged
MaojiaSheng merged 1 commit intovolcengine:mainfrom Mar 4, 2026
Merged
Conversation
MaojiaSheng
approved these changes
Mar 4, 2026
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.
Description
Improve ISO 8601 datetime parsing to accept
Z-suffix timestamps and trim excessive fractional seconds, then use this parser across core read paths.Related Issue
Fixes #
Root Cause
Two related parsing gaps caused valid timestamps to fail:
datetime.fromisoformat()does not acceptZsuffix (e.g.,2026-03-03T01:26:14.481Z).fromisoformat()rejects.These inputs appear in stored context/message timestamps, leading to
ValueErrorduring deserialization.Changes Made
openviking/utils/time_utils.pyZ->+00:00and trim excessive fractional seconds before parsing.openviking/core/context.pyparse_iso_datetime()forcreated_atandupdated_at.openviking/message/message.pyparse_iso_datetime()for messagecreated_at.openviking/retrieve/hierarchical_retriever.pyparse_iso_datetime()when parsingupdated_at.tests/unit/test_time_utils.pyZ-suffix parsing and context deserialization.Design Decisions
parse_iso_datetime()already handled excess fractional seconds; the fix extends it to acceptZ.fromisoformat()still parse correctly.Testing
Before:
Context.from_dict({"created_at": "2026-03-03T01:26:14.481Z"})->ValueErrorAfter:
parse_iso_datetime("2026-03-03T01:26:14.481Z")-> timezone-awaredatetimeContext.from_dict(...)-> parses without errorTests:
python -m pytest tests/unit/test_time_utils.pyType of Change
Checklist