Skip to content

fix(api): serialize response datetimes as UTC - #2220

Open
justonemorenight wants to merge 1 commit into
repowise-dev:mainfrom
justonemorenight:codex/fix-api-utc-datetimes
Open

fix(api): serialize response datetimes as UTC#2220
justonemorenight wants to merge 1 commit into
repowise-dev:mainfrom
justonemorenight:codex/fix-api-utc-datetimes

Conversation

@justonemorenight

Copy link
Copy Markdown
Contributor

What

Fixes #2174 by making REST datetime responses explicit UTC values.

SQLite drops tzinfo when round-tripping SQLAlchemy datetime columns, so API responses such as started_at arrived as suffix-less ISO strings. Browsers then interpreted them as local time, making elapsed job timers start at the viewer’s UTC offset (or stay at zero west of UTC).

Changes

  • Add one shared UTCDateTime Pydantic type for REST response schemas.
  • Serialize naive database values as UTC and aware values normalized to UTC, using an explicit Z suffix.
  • Apply it to all 30 datetime response fields across repository, page/job, git, ownership, decision, code-quality, and chat schemas.
  • Keep persistence unchanged; this is an API-boundary compatibility fix for existing SQLite and PostgreSQL data.

This covers the affected consumers called out in #2174: job elapsed/finished timestamps, repository timestamps, conversation age, dead-code timestamps, and git/ownership timestamps.

Tests

  • uv run ruff check packages/server/src/repowise/server/schemas tests/unit/server/test_datetime_serialization.py
  • uv run pytest tests/unit/server/test_datetime_serialization.py tests/unit/server/test_repos.py tests/unit/server/test_pages.py tests/unit/server/test_git.py tests/unit/server/test_chat_router.py tests/unit/server/test_decisions_api.py tests/unit/server/test_stats_contributors.py -q — 108 passed
  • uv run pytest tests/unit/server --ignore=tests/unit/server/mcp -q — 1,391 passed

The full API contract remains backward-compatible for consumers that parse ISO-8601 timestamps; the only change is that UTC is now declared instead of being inferred as browser-local time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Job elapsed timer starts at the viewer's UTC offset instead of zero (naive timestamps in API responses)

1 participant