Repository navigation
fix: Serialize datetime values as UTC with a Z suffix - #754
Open
gjtorikian wants to merge 1 commit into
Open
gjtorikian wants to merge 1 commit into
gjtorikian wants to merge 1 commit into
Conversation
The API only accepts the `Z` form for date-time parameters, so `range_start=datetime.now(UTC).isoformat()` was rejected with a 400 (#743). Generated resources type these params as `str` and forward them untouched, which leaves callers to discover the exact format by trial and error. Accepting `datetime` objects in query strings and JSON bodies gives callers a path that cannot produce a rejected timestamp. Aware values are converted to UTC first and naive values are assumed to be UTC, matching the API contract and the legacy `utcnow()` habit. Strings still pass through untouched. Refs #743
Contributor
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryThe PR sends
gjtorikian explicitly deferred changing generated date parameter annotations from
|
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.
Description
events.list_events(range_start=datetime.now(UTC).isoformat())was rejected by the API withinvalid_date_range_exception(Eventsrange_startrejectsdatetime.isoformat()output #743). The API accepts only theZform for date-time parameters, and generated resources type them asstrand forward them untouched, so callers had to discover the exact format by trial and error.datetimeobjects._query_valueand_encode_bodyin_base_client.pyroute them through_format_datetime, which now converts aware values to UTC and assumes naive values are UTC before emitting2026-10-01T18:01:14.870Z._format_datetimealso backs generatedto_dict, so model fields set to non-UTC datetimes now serialize in the form the API accepts instead of carrying an offset.format: date-timein the API repo, and the Python emitter will type date-time parameters asUnion[datetime, str]so this path also type-checks. Until then it works at runtime but a type checker will flag thestrannotation.Closes #743