fix(routing): tolerate malformed historical attempts - #1187
Conversation
📝 WalkthroughWalkthroughRouting analytics now validates historical ChangesRouting analytics hardening
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏳ DRAFT
What to do
Review readiness checklist
1/4 boxes ticked. This PR stays in draft until every box above is ticked. |
|
✅ Deterministic PR hygiene checks passed. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
8b413ac to
36cffce
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Approved the pending Cross-platform CI run at this exact head so it can actually execute — To be clear about what that does and doesn't do: it only unblocks CI. It does not make this mergeable. The four-box readiness checklist is your attestation, not something a maintainer ticks for you, and the gate keeps the PR in draft until you complete it. Once CI comes back green, tick the boxes and it moves to ready on its own. If the run comes back red, tell me and I'll dig into it rather than leaving you to guess. |
Summary
attemptsvalues in routing analytics;recoveryKindsarray before reading it;Why
The usage log is append-only history and older or partially malformed rows may not satisfy the current TypeScript shape. The analytics reader parsed each row and then called
.some()onattemptsandrecoveryKindswithout runtime validation. A malformed historical row could therefore throw and make the read-only analytics endpoint unavailable.The writer format is unchanged. This patch makes only the historical reader defensive and treats malformed recovery metadata as non-triggering rather than inventing a cooldown signal. An explicit HTTP 429 remains cooldown-triggering independently of malformed attempt metadata.
Verification
tests/routing-analytics.test.ts11/11 passed, 47 assertions.5f65d3785): the same suite 11/11 passed, 47 assertions.bun x tsc --noEmit: passed.bun scripts/privacy-scan.ts: passed.git diff --check: passed.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
Bug Fixes
Tests