Repository navigation
fix: report invalid pending capture times per sidecar - #1757
Merged
Merged
Conversation
The read-only sidecar scanner took MIN(created_at) over pending and retry rows. created_at is unvalidated TEXT, so a valid timestamp could win the lexicographic minimum and hide an invalid one in the same sidecar; #1637 only made the fold across sidecars sticky. Return an invalid pending or retry created_at when one exists, otherwise the valid minimum. Validity is a shape GLOB, a datetime() round trip, and an hour < 24 guard. The hour guard is needed because datetime() leaves 24:00:00 unchanged. The result feeds the existing out-of-range handling. oldestDeliveryAt and other counters are unchanged. Fixes #1737 Signed-off-by: Bernardo Donadio <bcdonadio@bcdonadio.com>
bcdonadio
enabled auto-merge
October 25, 2026 06:43
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Closes #1737
Why
The read-only sidecar scanner computed each sidecar's oldest pending capture time with a plain
MIN(created_at)over unvalidated TEXT. When one sidecar held a valid pending row (2026-02-03 11:59:00) and an invalid one (not-a-timestamp,2026-02-30 10:00:00,2026-03-01 24:00:00), the lexicographic minimum returned the valid value, so runtime health reported an observed pending age and hid the invalid row. #1637 made the fold across sidecars sticky on invalid values, but never saw the invalid value inside a single sidecar.How
src/db/event-sidecars.ts:oldestPendingAtis nowCOALESCE(MIN(created_at) FILTER (pending/retry AND NOT valid), MIN(created_at) FILTER (pending/retry)). An invalid pending or retry value is returned when one exists, so the existing Pending-age fold hides invalid sidecar timestamps #1637 fold andlocalPendingAgeReadreportout-of-range; otherwise the valid minimum is returned as before. Validity is a shapeGLOB, acreated_at IS datetime(created_at)round trip (rejects impossible dates such as 02-30), and an hour guard (datetimekeeps24:00:00unchanged). This agrees withsqliteUtcMsinsrc/storage/runtime-health.ts. Only the pending column changes.docs/cli.md,postgresql-telemetry.md) now say the age is omitted when any pending or retry local event has an invalid capture time.Testing
test/db/events-stats.test.ts: each invalid value in a fresh sidecar next to a valid earlier row yields the invalid string andout-of-range; an invalid retry row counts; an invalid quarantined row is ignored.24:00:00case fails when only the hour guard is removed.events-stats*andcodecov-configtests,tsc --noEmitand eslint pass;src/db/event-sidecars.tsis at 100% across the sidecar test files.Reviewer guide
Start with the SQL and
VALID_CREATED_AT_SQLinsrc/db/event-sidecars.ts, then the new cases intest/db/events-stats.test.ts.oldestDeliveryAtand other counters are intentionally untouched.