fix(claim): stop claim page crashing on links with no events relation - #2889
Conversation
The API stopped selecting the SendLink `events` relation post-ledger-collapse, so `claimLinkData.events` is now always undefined. Claim.tsx dereferenced `events[0]` with the optional chain on the wrong side of the index, throwing "Cannot read properties of undefined (reading '0')" inside a render-phase useMemo — which Next.js surfaces as "Application error: a client-side exception has occurred" (Sentry PEANUT-UI-SJ0). Guard the array itself and mark `events` optional on the SendLink type so the compiler catches the next orphaned access.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Code-analysis diffPainscore total: 7753.18 → 7753.44 (+0.26) 🆕 New findings (12)
✅ Resolved (12)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughThe change makes ChangesSendLink event handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This change prevents cancelled send-link pages from crashing when the events relation is absent and updates the type to allow that response shape. No actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Chip review — no blocking findings — this is not an approval
Clean. The fix guards the optional events array before indexing, preserves the cancellation timestamp when present, and aligns the SendLink type with the runtime wire shape. No actionable correctness, security, adversarial, or slop issues found.
Checked clean
- Verified the exact head SHA, supplied base SHA, and merge base; the diff is limited to Claim.tsx and the SendLink type.
- Exercised the cancelled-link logic mentally with events omitted, empty, and populated; all paths now render without changing the populated timestamp behavior.
- Swept every remaining SendLink events access and confirmed each already guards an omitted array.
- Checked the backend send-link projection and prior claim-receipt history to confirm that optional frontend handling is compatible with the wire shape.
- Reviewed trust boundaries, authorization, secret exposure, mutation behavior, duplication, naming, and architecture drift; this patch introduces none.
- Exact-head typecheck, ESLint, format, unit, E2E, CodeQL JavaScript analysis, and JavaScript/TypeScript code scanning checks passed.
Second opinion by moonshotai/kimi-k3: 0 finding(s), marked with the model name. It reads the diff only, so treat its findings as advice.
Exact head: 94bbdccf67bb · Context: repo, mono
Problem
Opening a send link on production shows "Application error: a client-side exception has occurred" — the page never renders.
Sentry: PEANUT-UI-SJ0 —
TypeError: Cannot read properties of undefined (reading '0')atsrc/components/Claim/Claim.tsx:184, on release85079d7e(currentmain, from the dev→main merge #2879). 2 users so far, plus the same crash in thenativeenv.Cause
peanut-api-tsdropped theeventsrelation fromSEND_LINK_SELECT("Post-ledger-collapse: SendLink no longer hasclaim/claimAttempts/eventsrelations"), soGET /send-links/:idno longer returns aneventsfield at all.Claim.tsxstill dereferenced it:The optional chain sits on the wrong side of the index —
events[0]?.timestampstill throws wheneventsitself is undefined. (3b6055bc7patched this same line but placed the?.after the subscript.)It throws inside a
useMemoduring render, so React unwinds the tree and Next.js paints the generic client-exception screen rather than anything actionable.Note the trigger is the
status === 'cancelled'branch — the ternary short-circuits for other statuses, so this hits cancelled links.Fix
eventsoptional on theSendLinktype. It was declared required, which is exactly why the compiler never flagged the dereference.Scope check
Swept every remaining access to the removed relations.
Claim.tsx:169(events?.find),useClaimSuccessPolling.ts:28(events?.[…]) and all fiveclaim?.sites were already guarded — line 184 was the only unguarded one.tsc --noEmitis clean witheventsnow optional, which confirms nothing else relied on it being present.Summary by CodeRabbit