fix(domains): crash-proof DomainCard against unexpected status values #4049
Cross-repo impact
See what breaks downstream if this PR merges.
⮌ Merged
This pull request was merged into main.
c comment · e edit title · m merge · a approve · r request changes · ? shortcuts
Originally written by @ccantynz-alt on GitHub.
Imported from https://github.com/ccantynz-alt/AlecRae.com/pull/82
Summary
DomainCardaccessedstateStyles[verificationState]without a fallback — if the value wasnull,undefined, or any unexpected string,stateStyles[...]returnedundefinedandstate.bgthrew aTypeErrorduring React rendering, which the error boundary caught and showed "Something went wrong"mapDomainused a loose runtime type cast (as "pending" | "verified" | "failed") that silently passed through bad values rather than explicitly normalising themChanges
packages/ui/src/composites/domain-card.tsx// before const state = stateStyles[verificationState]; // after const state = stateStyles[verificationState] ?? stateStyles.pending;apps/web/app/(dashboard)/domains/page.tsxReplaced the implicit cast with an explicit exhaustive mapping:const verificationState = rawStatus === "verified" ? "verified" : rawStatus === "failed" ? "failed" : rawStatus === "expired" ? "expired" : "pending"; // covers "verifying", "pending", null, undefined, unknownWhy this fixes it
React render-time
TypeErrors go to the error boundary (not totry/catchin async data-loading code). So even thoughloadDomainswas fully wrapped in try/catch, a crash insideDomainCard's render escaped into the boundary and showed the "Something went wrong" page.Test plan
/domains— no error boundaryDomainCardrenders for all status values (pending, verifying, verified, failed, expired)Box deploy note
After merging to main, run the pull ritual on the box to pick up this fix:
https://claude.ai/code/session_01SQnsrDnjuwbSRbL7kEKg35
Generated by Claude Code