Repository navigation
fix(cron): compare order timestamps as instants, not text - #125
Merged
Merged
Conversation
orders.created_at defaults to 'YYYY-MM-DD HH:MM:SS' and updated_at is rewritten as ISO-8601 by the services. Against an ISO cutoff the text comparison sorts ' ' before 'T', so an order created later the same UTC day already looked older than the cutoff: expire-orders could expire a fresh CREATED order and reconcile-payments polled orders too early. Read both spellings as UTC timestamps and compare instants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ThreatCrush Security Scan1 finding(s) MEDIUM: 1
Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
orders.created_at/updated_atare TEXT. The column default writesYYYY-MM-DD HH:MM:SS, while the services write ISO-8601 (...T...Z) on update.expire-ordersandreconcile-paymentscompared them with an ISO cutoff using drizzlelt(), which is a text comparison.' 'sorts before'T', so any order from later the same UTC day counted as older than the cutoff.On the prod data, both orders created at
2026-10-21 12:18test as older than a2026-10-21T10:00:00Zcutoff:So
expire-orderscould expire a CREATED order hours after it was made instead of afterEXPIRE_AFTER_HOURS, and reconciliation picked up orders beforeRECONCILE_AFTER_MINUTES.Fix
olderThan(column, cutoffIso)compares(column::timestamp at time zone 'utc') < cutoff::timestamptz. Both stored spellings parse, both are UTC, and the result does not depend on the session time zone. No schema change.tscclean for services/cron,vitest run: 506 pass.🤖 Generated with Claude Code