fix: convert deploy timestamps to UTC before sending#219
Merged
Conversation
`deploys add` and `update-by-uuid` captured the local wall-clock time via datetime.now() and formatted it with a hardcoded "Z" suffix, putting local time on the wire mislabeled as UTC. The backend trusts the offset, so the deploy shows up shifted by the client's UTC offset in the UI. Interpret the naive timestamp as local time and convert to UTC before formatting, so the "Z" is accurate. Covers both the default "now" and an explicit --timestamp. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hannavigil
marked this pull request as ready for review
July 13, 2026 20:41
Cantaley
approved these changes
Jul 14, 2026
Cantaley
left a comment
There was a problem hiding this comment.
Approved. Minor note: it looks like this is a behavior change for existing users, so I am assuming we'll call it out in the release notes? Users who were compensating for the old behavior (if any) may be affected.
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.
Problem
cortex deploys add(with no--timestamp) returns a timestamp that displays with the wrong time in the Cortex UI. Example — run at 11:26 PDT:{ "timestamp": "2026-07-13T11:26:52Z", ... }11:26was the local wall-clock time, but it's labeledZ(UTC). The true UTC was18:26. So every deploy is off by the client's UTC offset.Root cause
In
cortexapps_cli/commands/deploys.py:timestamp: datetime = typer.Option(datetime.now(), ...)Z:data["timestamp"].strftime('%Y-%m-%dT%H:%M:%SZ')So local time goes on the wire mislabeled as UTC. The backend (brain-backend) trusts the offset and round-trips the instant faithfully — the bug is entirely client-side.
Fix
Interpret the naive timestamp as local time and convert to UTC before formatting, so the
Zis truthful..astimezone(timezone.utc)treats a naive datetime as the machine's local time. Applied to bothaddandupdate-by-uuid; covers thedatetime.now()default and an explicit--timestamp.Behavior note: an explicit
--timestamp 2026-07-13T10:00:00(which carries no offset) is now interpreted as local and converted to UTC, rather than being sent as-is-with-Z. This is consistent with thedatetime.now()default and matches what a human means when typing a wall-clock time.Tests
Added
tests/test_deploys_timestamp.py— mocks the POST (viaresponses), pins a fixed offset zone, and asserts the outgoing payload's timestamp is converted to UTC (10:30local UTC-5 →15:30:00Z). Pre-fix code emitted10:30:00Z, so this is a regression guard.Out of scope (flagging for follow-up)
update-by-uuid's flag-based path has a separate, pre-existing bug: its guardif not title or tag or deploy_type:is always truthy (sincetagis required), so it raises before sending whenever-fisn't used. The timestamp fix on that line is correct but currently only reachable once that guard is fixed. Not addressed here to keep this PR focused.🤖 Generated with Claude Code