Skip to content

fix(quota-planner): normalize datetimes before database use#1043

Open
zvladru wants to merge 2 commits into
Soju06:mainfrom
zvladru:fix/quota-planner-utc-timestamps
Open

fix(quota-planner): normalize datetimes before database use#1043
zvladru wants to merge 2 commits into
Soju06:mainfrom
zvladru:fix/quota-planner-utc-timestamps

Conversation

@zvladru

@zvladru zvladru commented Jun 17, 2026

Copy link
Copy Markdown

Problem

The quota planner can handle timezone-aware datetimes from scheduler/runtime code, while the database columns and query comparisons are treated as UTC-naive timestamps. In Postgres setups this can surface as scheduler/database errors when aware values are written to timestamp without time zone columns or compared against naive stored values.

Changes

  • Add a small repository helper that normalizes optional datetimes to naive UTC before database use.
  • Normalize scheduled_at, executed_at, and quota-window observed_at values before writes.
  • Normalize since bounds before executed-warmup counts, warmup-cost queries, and demand-history queries.

Impact

This keeps the quota planner's database boundary consistent: application code may pass aware datetimes, while persistence/query code stores and compares naive UTC values. It avoids scheduler failures caused by timezone-aware values reaching naive DB fields.

Tests

  • uv run pytest -q tests/unit/test_quota_planner.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f34df1c66b

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

Comment thread tests/unit/test_quota_planner.py
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 17, 2026
@zvladru

zvladru commented Jun 18, 2026

Copy link
Copy Markdown
Author

Addressed the automated review feedback in dc3a4910 by adding repository/session-boundary coverage for aware datetime normalization.

@codex review

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 18, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: dc3a491065

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

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.

2 participants