Skip to content

Audit DateTimeOffset-vs-TEXT comparison sites for missing UTC normalization (convention-only invariant after #1403/#1421) #1422

Description

@Chris0Jeky

Seam

Repositories that compare a caller-supplied DateTimeOffset against a SQLite-stored TEXT timestamp column rely on the caller passing UTC. PR #1421 (issue #1403) fixed the four known boundary sites and hardened them with .ToUniversalTime() at the bound, after its review empirically confirmed EF's SQLite mapping preserves the source offset — a non-UTC bound compares as an offset-preserving string, not as an instant.

Gap

LlmQueueRepository.GetStuckProcessingNonCaptureAsync (the proven parameterized pattern #1421 mirrored) — and potentially other query sites — pass the caller's DateTimeOffset through without normalizing to UTC. Today every caller passes UTC, so behavior is correct; but the invariant is enforced by convention only. A future caller passing a local-offset value would silently compare by offset-preserved string and mis-select rows (the exact failure class PR #1421's review caught and fixed at its own sites, severity HIGH there).

Suggested direction

Sweep backend/src/Taskdeck.Infrastructure/Repositories/ for every raw-SQL or interpolated query that binds a DateTimeOffset parameter compared against a stored TEXT timestamp; either add .ToUniversalTime() at the bind site (cheap, local, matches #1421's pattern) or centralize via a small helper. Add one regression test per fixed site with a non-UTC-offset bound (the DeleteOldEntriesAsync_WithNonUtcCutoff_ComparesByInstant_NotOffsetPreservedString test from PR #1421 is the template).

Provenance

Seeded from PR #1421's implementation round (issue #1403), overnight run 2026-07-18 — the worker's residual note flagged the convention-only invariant; tracked per review policy (no silent drops).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority IVLater maturity/deepening; revisited at horizon planning.tech-debtDebt cleanup or deferred engineering quality work with limited product-surface change.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions