Fix inconsistent ISO timestamp formatting causing ValueError on step update#2798
Open
hztBUAA wants to merge 1 commit intoChainlit:mainfrom
Open
Fix inconsistent ISO timestamp formatting causing ValueError on step update#2798hztBUAA wants to merge 1 commit intoChainlit:mainfrom
hztBUAA wants to merge 1 commit intoChainlit:mainfrom
Conversation
…update Timestamps were saved with trailing Z (UTC indicator) but read back via .isoformat() without Z, causing a ValueError when update_step tried to re-parse the createdAt string via strptime with the Z-requiring format. Changes: - Add _parse_iso_datetime() helper that handles both with/without Z - Add _datetime_to_utc_iso() helper that ensures trailing Z on output - Replace all .isoformat() calls with _datetime_to_utc_iso() - Replace strptime(created_at, ISO_FORMAT) with _parse_iso_datetime() - Switch datetime.now() to datetime.utcnow() for UTC consistency - Add tests covering parse/format roundtrip and step row conversion Fixes Chainlit#2491
Collaborator
|
Would love to merge this, please run |
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.
Summary
Fixes #2491
ChainlitDataLayersaves timestamps with a trailingZ(e.g.,2025-09-04T02:00:42.164000Z) viaISO_FORMAT, but reads them back using Python's.isoformat()which omits theZ(e.g.,2025-09-04T02:00:42.164000). Whenupdate_stepcallscreate_stepwith the read-backcreatedAtstring,strptimefails with:Changes
_parse_iso_datetime()helper that tolerates both with and without trailingZ_datetime_to_utc_iso()helper that ensures all datetime-to-string conversions consistently include the trailingZ.isoformat()calls with_datetime_to_utc_iso()across user, thread, and step serializationdatetime.strptime(created_at, ISO_FORMAT)with_parse_iso_datetime(created_at)increate_stepdatetime.now()todatetime.utcnow()inget_current_timestamp()andupdate_thread()for correct UTC semanticsTest plan
_parse_iso_datetimecorrectly parses both"...Z"and"..."formats_datetime_to_utc_isoalways produces strings ending withZcreate_stepValueErrorSummary by cubic
Fix inconsistent ISO timestamp handling to prevent ValueError during step updates. Standardizes UTC timestamps with a trailing Z and makes parsing accept both formats.
Written for commit 9b70738. Summary will update on new commits.