Skip to content

fix(api-keys): normalize timezone-aware expirations before persistence#249

Merged
Soju06 merged 1 commit intoSoju06:mainfrom
yigitkonur:fix/api-key-expiry-timezone
Mar 24, 2026
Merged

fix(api-keys): normalize timezone-aware expirations before persistence#249
Soju06 merged 1 commit intoSoju06:mainfrom
yigitkonur:fix/api-key-expiry-timezone

Conversation

@yigitkonur
Copy link
Copy Markdown
Contributor

Summary

  • normalize timezone-aware expiresAt values to UTC-naive datetimes before API key create/update writes
  • add unit regression coverage for create and update flows with offset-aware datetimes
  • document the accepted expiresAt behavior in OpenSpec

Notes

Testing

  • uv run pytest tests/unit/test_api_keys_service.py -q
  • uv run ruff check app/modules/api_keys/service.py tests/unit/test_api_keys_service.py
  • python3 -m compileall app/modules/api_keys/service.py tests/unit/test_api_keys_service.py
  • uv run openspec validate --specs (fails in this environment because the openspec executable is not installed)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_at via to_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 expiresAt behavior.

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.

@Soju06
Copy link
Copy Markdown
Owner

Soju06 commented Mar 24, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@Soju06
Copy link
Copy Markdown
Owner

Soju06 commented Mar 24, 2026

Thank you for your contribution!

@Soju06
Copy link
Copy Markdown
Owner

Soju06 commented Mar 24, 2026

@all-contributors please add @yigitkonur for bug, code

@Soju06 Soju06 added the bug Something isn't working label Mar 24, 2026
@allcontributors
Copy link
Copy Markdown
Contributor

@Soju06

I've put up a pull request to add @yigitkonur! 🎉

@Soju06 Soju06 merged commit abf96f8 into Soju06:main Mar 24, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants