Repository navigation
Description
Summary
A notice with an expires_at later today keeps being served as active until the next calendar day (UTC). Expiries on a previous date work correctly, so this looks like it works most of the time.
Root cause
expires_at is stored in ISO-8601 with a T separator, because POST /admin/notices validates it with z.string().datetime({ offset: true }) (backend/src/routes/admin/notices.ts:32) and createNotice binds the value through unnormalized (backend/src/services/notices.ts:79).
getActiveNotices then filters with:
WHERE (expires_at IS NULL OR expires_at > datetime('now'))datetime('now') emits YYYY-MM-DD HH:MM:SS — a space separator, no Z. Both sides are TEXT, so this is a byte comparison under the default BINARY collation. T is 0x54, space is 0x20, so whenever the date portions are equal the ISO value always compares greater and the notice is treated as unexpired.
Verified:
sqlite3 :memory: "SELECT '2026-07-25T00:00:00.000Z' > '2026-07-25 09:00:00';" -- 1 (expired, reported active)
sqlite3 :memory: "SELECT '2026-07-24T00:00:00.000Z' > '2026-07-25 09:00:00';" -- 0 (correct)
The first row is a notice that expired at midnight still being served at 09:00.
Impact
Bounded but real: an expired notice keeps showing to CLI users (and to GET /notices consumers) for the remainder of the UTC day. It self-corrects at the next date rollover, which is probably why it hasn't been noticed. A same-day "maintenance window ends at 14:00" notice is exactly the case that misbehaves.
Worth noting the CLI already sidesteps this: src/commands/admin.ts:5334 computes expiry client-side with new Date(notice.expires_at) < new Date() rather than trusting the server's filter, so nemar admin notices list disagrees with what GET /notices actually serves.
Suggested fix
Either normalize on write so the stored format matches what SQLite's date functions emit:
INSERT INTO notices (..., expires_at) VALUES (..., datetime(?))or compare in the same format as the stored value:
WHERE (expires_at IS NULL OR expires_at > strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))Normalizing on write is the sturdier of the two — it also makes the existing idx_notices_expires index comparisons well-defined — but it needs a backfill for rows already stored in ISO form.
Found via
Scoping the website admin portal's notices tab (nemarOrg/website epic #158 Phase 5). The website will compute expiry client-side in its admin list for the same reason the CLI does, so admins see the true state regardless of which fix lands.
Activity
neuromechanist commentedon Jul 25, 2026
Merged to
devin #1027 (a93d330). Closing by hand —Closes #Ndoesn't fire for PRs merged into a non-default branch.Fixed by normalizing
expires_aton write (datetime(?)plus migration 0064 to backfill) so the comparison againstdatetime('now')is like-for-like, and projecting both timestamps back as explicit-UTC RFC3339 so no JS consumer parses them as local time.Reaches production when
devis promoted tomain.