Skip to content

fix(audit): preserve timezone-naive operation log timestamps - #1419

Merged
xuwei-fit2cloud merged 1 commit into
mainfrom
codex/fix-audit-time-filter
Oct 27, 2026
Merged

xuwei-fit2cloud merged 1 commit into
mainfrom
codex/fix-audit-time-filter

Conversation

@xuwei-fit2cloud

Copy link
Copy Markdown
Collaborator

Filtering operation logs by time raises a timezone error on SQLModel 0.0.45 and later because its inferred datetime type requires aware parameters. Audit writers and time-range queries use naive datetimes, and migration 055 creates sys_logs.create_time as TIMESTAMP WITHOUT TIME ZONE.

Declare the existing SQLAlchemy type explicitly so filtering, log inserts, and returned timestamps retain their established behavior. This aligns ORM metadata with the existing database column; no schema or data migration is needed.

Validation:

  • Reproduced the reported time-range query error and default log-insert failure on the unmodified source with SQLModel 0.0.45 and 0.0.48.
  • Passed 7 local checks each on SQLModel 0.0.31, 0.0.45, and 0.0.48 (21 checks), exercising the packaged audit API routes against isolated PostgreSQL: no filter, the reported range with inclusive boundaries and millisecond exclusions, pagination, empty results, combined status filtering, Excel export, and default inserts. Returned timestamps were checked for timezone shifts.
  • Compilation, diff checks, and Alembic's single-head check passed. Existing Ruff diagnostics remain: 20 UP045 warnings and a formatting discrepancy, verified on the unmodified baseline; the import-order warning was resolved.
  • The route harness overrides database and translation dependencies; full browser, product authentication/license, and container deployment acceptance were not performed. Test scripts and fixtures remain local and are excluded from this PR as requested.

Reference: SQLModel datetime compatibility change.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 05:47

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@xuwei-fit2cloud
xuwei-fit2cloud merged commit 368f9fd into main Oct 27, 2026
3 checks passed
@xuwei-fit2cloud
xuwei-fit2cloud deleted the codex/fix-audit-time-filter branch October 27, 2026 05:48
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