fix(api-keys): normalize timezone-aware expirations before persistence#249
Conversation
There was a problem hiding this comment.
Pull request overview
Normalizes API key expires_at inputs that include timezone offsets to UTC-naive datetimes before writing to the database, preventing PostgreSQL timestamp without time zone binding failures while keeping the external API contract unchanged.
Changes:
- Normalize
expires_atviato_utc_naive()in API key create and update flows before persistence. - Add unit regression tests covering create/update with offset-aware datetimes.
- Update OpenSpec documentation and change artifacts to specify/track the accepted
expiresAtbehavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| app/modules/api_keys/service.py | Normalizes expires_at to UTC-naive for create/update persistence via a helper. |
| tests/unit/test_api_keys_service.py | Adds regression tests ensuring timezone-aware expirations are stored/returned as UTC-naive. |
| openspec/specs/api-keys/spec.md | Documents timezone-aware expiresAt acceptance and UTC normalization expectations. |
| openspec/changes/fix-api-key-expiration-timezone/tasks.md | Tracks the change checklist for normalization/tests/spec updates. |
| openspec/changes/fix-api-key-expiration-timezone/specs/api-keys/spec.md | Captures the spec deltas for the change archive. |
| openspec/changes/fix-api-key-expiration-timezone/proposal.md | Provides rationale/impact statement for the normalization behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Thank you for your contribution! |
|
@all-contributors please add @yigitkonur for bug, code |
|
I've put up a pull request to add @yigitkonur! 🎉 |
Summary
expiresAtvalues to UTC-naive datetimes before API key create/update writesexpiresAtbehavior in OpenSpecNotes
Testing
uv run pytest tests/unit/test_api_keys_service.py -quv run ruff check app/modules/api_keys/service.py tests/unit/test_api_keys_service.pypython3 -m compileall app/modules/api_keys/service.py tests/unit/test_api_keys_service.pyuv run openspec validate --specs(fails in this environment because theopenspecexecutable is not installed)