fix: gracefully fallback on invalid variant props instead of crashing#469
fix: gracefully fallback on invalid variant props instead of crashing#469mattrothenberg wants to merge 2 commits intomainfrom
Conversation
Every component variant function now uses a shared resolveVariant() utility that returns the default config when an unknown variant key is passed at runtime. Previously 22 of 25 components would throw TypeError on invalid variants while 3 silently fell back — now all 25 behave consistently. Includes regression tests for every variant function.
|
/bonk please carefully review and approve |
commit: |
Docs PreviewCommit: |
|
@mattrothenberg Bonk workflow was cancelled. View workflow run · To retry, trigger Bonk again. |
|
/bonk |
PR Thread SummaryPR #469: fix: gracefully fallback on invalid variant props instead of crashing What Changed
Thread Activity
Status
|
|
/bonk review the approach and approve the PR |
There was a problem hiding this comment.
Approving this well-executed fix.
Summary:
- Clean abstraction with resolveVariant() utility that safely handles invalid variant props
- 25 components updated with consistent fallback behavior
- 34 comprehensive regression tests all passing
- Non-breaking change with helpful dev-only warnings
- Changeset properly included
The approach elegantly solves the runtime crash issue while maintaining backward compatibility.
|
I've approved PR #469. Approval Summary: This PR provides a clean, well-tested solution to prevent runtime crashes when invalid variant props are passed to Kumo components. The
The 34 new tests provide solid regression coverage, and the changeset is properly configured for a patch release. Good work! |













































Summary
resolveVariant()utility (src/utils/resolve-variant.ts) that safely resolves variant config objects with fallback to the default when an unknown key is passed, plus a dev-onlyconsole.warnTypeError: Cannot read properties of undefined (reading 'classes')on invalid variant values, while 3 (Badge, Code, Switch) had ad-hoc fallback logiciconClasses), Toast (icon), ClipboardText (buttonSize), Text (component body), and Table (stickyColumnClasses)No default behavior changed — verified that the 3 previously-safe components used identical fallback keys.