Repository navigation
fix(Icon): keep malformed slot diagnostics from interrupting rendering - #11502
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| TextInput | 72.6 kB (+21 B) · 12.0 kB CSS (0) | — | — · — · — |
| TimeInput | 174.4 kB (+9 B) · 16.9 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 298.3 kB (+5 B) · 454 B CSS (0) | — | — · — · — |
112 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/Schedule | 114.3 kB (+4 B) · 3.9 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 68.6 kB (+4 B) · 162 B CSS (0) | — | — · — · — |
| ChatSendButton | 65.2 kB (+3 B) · 10.8 kB CSS (0) | — | — · — · — |
| InputGroup | 60.9 kB (+3 B) · 7.9 kB CSS (0) | — | — · — · — |
| ListItem | 74.8 kB (+3 B) · 11.7 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 65.4 kB (+2 B) · 11.0 kB CSS (0) | — | — · — · — |
| CheckboxList | 73.0 kB (+2 B) · 7.8 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 75.6 kB (+2 B) · 11.7 kB CSS (0) | — | — · — · — |
| Collapsible | 28.9 kB (+2 B) · 4.5 kB CSS (0) | — | — · — · — |
| Typeahead | 87.4 kB (+2 B) · 13.3 kB CSS (0) | — | — · — · — |
| lab/TabBarMoreList | 97.5 kB (+2 B) · 1.8 kB CSS (0) | — | — · — · — |
| Carousel | 74.5 kB (+1 B) · 11.7 kB CSS (0) | — | — · — · — |
| ChatComposer | 84.3 kB (+1 B) · 12.9 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 65.4 kB (+1 B) · 10.8 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 34.3 kB (+1 B) · 7.6 kB CSS (0) | — | — · — · — |
| ComplexSelector | 77.4 kB (+1 B) · 12.6 kB CSS (0) | — | — · — · — |
| FieldStatus | 10.1 kB (+1 B) · 3.6 kB CSS (0) | — | — · — · — |
| NumberInput | 77.4 kB (+1 B) · 12.2 kB CSS (0) | — | — · — · — |
| SelectorOption | 21.6 kB (+1 B) · 6.4 kB CSS (0) | — | — · — · — |
| SideNavHeading | 82.3 kB (+1 B) · 12.1 kB CSS (0) | — | — · — · — |
| Slider | 114.3 kB (+1 B) · 8.9 kB CSS (0) | — | — · — · — |
| Thumbnail | 69.2 kB (+1 B) · 12.3 kB CSS (0) | — | — · — · — |
| TopNavMenu | 81.4 kB (+1 B) · 12.0 kB CSS (0) | — | — · — · — |
| AppShell | 97.1 kB (0) · 14.3 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 91.6 kB (0) · 12.9 kB CSS (0) | — | — · — · — |
| Button | 64.8 kB (0) · 10.8 kB CSS (0) | — | — · — · — |
| Calendar | 75.9 kB (0) · 11.4 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 81.9 kB (0) · 12.1 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 81.9 kB (0) · 12.1 kB CSS (0) | — | — · — · — |
| ChatMessageMetadata | 20.4 kB (0) · 4.1 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 34.9 kB (0) · 8.4 kB CSS (0) | — | — · — · — |
| CommandPalette | 76.3 kB (0) · 12.7 kB CSS (0) | — | — · — · — |
| ContextMenu | 117.5 kB (0) · 18.3 kB CSS (0) | — | — · — · — |
| DateInput | 199.6 kB (0) · 17.9 kB CSS (0) | — | — · — · — |
| DateRangeInput | 99.1 kB (0) · 13.3 kB CSS (0) | — | — · — · — |
| DateTimeInput | 223.1 kB (0) · 19.7 kB CSS (0) | — | — · — · — |
| DialogHeader | 67.7 kB (0) · 12.3 kB CSS (0) | — | — · — · — |
| DrawerHeader | 67.9 kB (0) · 13.7 kB CSS (0) | — | — · — · — |
| DropdownMenuCheckboxItem | 23.9 kB (0) · 7.0 kB CSS (0) | — | — · — · — |
| DropdownMenuRadioItem | 23.9 kB (0) · 7.0 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 74.4 kB (0) · 10.1 kB CSS (0) | — | — · — · — |
| FieldLabel | 55.2 kB (0) · 5.8 kB CSS (0) | — | — · — · — |
| FileInput | 73.9 kB (0) · 11.7 kB CSS (0) | — | — · — · — |
| Icon · Storybook | 8.2 kB (0) · 681 B CSS (0) | 943 (+11) | ✓ · ✓ · — |
| InfoTip | 50.2 kB (0) · 5.4 kB CSS (0) | — | — · — · — |
| Lightbox | 145.1 kB (0) · 11.9 kB CSS (0) | — | — · — · — |
| Link | 56.2 kB (0) · 7.1 kB CSS (0) | — | — · — · — |
| MobileNav | 75.7 kB (0) · 11.4 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 65.2 kB (0) · 10.8 kB CSS (0) | — | — · — · — |
| MultiSelector | 101.1 kB (0) · 17.7 kB CSS (0) | — | — · — · — |
| Pagination | 120.9 kB (0) · 18.8 kB CSS (0) | — | — · — · — |
| Popover | 97.8 kB (0) · 15.1 kB CSS (0) | — | — · — · — |
| Selector | 109.8 kB (0) · 18.4 kB CSS (0) | — | — · — · — |
| SideNavItem | 76.8 kB (0) · 11.9 kB CSS (0) | — | — · — · — |
| Step | 31.5 kB (0) · 5.6 kB CSS (0) | — | — · — · — |
| Switch | 108.7 kB (0) · 10.0 kB CSS (0) | — | — · — · — |
| Table | 135.6 kB (0) · 19.2 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 118.3 kB (0) · 18.6 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 75.1 kB (0) · 14.0 kB CSS (0) | — | — · — · — |
| TabList | 47.1 kB (0) · 6.5 kB CSS (0) | — | — · — · — |
| TextArea | 66.6 kB (0) · 9.4 kB CSS (0) | — | — · — · — |
| Toast | 103.3 kB (0) · 11.1 kB CSS (0) | — | — · — · — |
| Token | 29.3 kB (0) · 4.8 kB CSS (0) | — | — · — · — |
| TopNav | 77.5 kB (0) · 11.7 kB CSS (0) | — | — · — · — |
| TopNavHeading | 81.9 kB (0) · 12.0 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 75.9 kB (0) · 12.6 kB CSS (0) | — | — · — · — |
| TreeList | 46.2 kB (0) · 5.9 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 113.9 kB (0) · 1.1 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 60.2 kB (0) · 1.2 kB CSS (0) | — | — · — · — |
| lab/DialogHeroHeader | 88.4 kB (0) · 372 B CSS (0) | — | — · — · — |
| lab/DiffViewer | 92.7 kB (0) · 2.1 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 92.2 kB (0) · 751 B CSS (0) | — | — · — · — |
| lab/ListInput | 93.3 kB (0) · 922 B CSS (0) | — | — · — · — |
| lab/NavigationScreen | 84.8 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/NavigationStack | 84.8 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/TabBar | 83.4 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
| lab/TabBarItem | 3.9 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
| lab/TourStep | 93.0 kB (0) · 691 B CSS (0) | — | — · — · — |
| lab/TransferList | 107.6 kB (0) · 1.2 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 116.5 kB (0) · 1.4 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 304.1 kB (0) · 2.6 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 281.8 kB (0) · 2.3 kB CSS (0) | — | — · — · — |
| AlertDialog | 111.3 kB (−1 B) · 15.4 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 78.1 kB (−1 B) · 11.7 kB CSS (0) | — | — · — · — |
| ChatLayout | 88.2 kB (−1 B) · 11.3 kB CSS (0) | — | — · — · — |
| Citation | 20.7 kB (−1 B) · 4.4 kB CSS (0) | — | — · — · — |
| DropdownMenu | 104.2 kB (−1 B) · 18.5 kB CSS (0) | — | — · — · — |
| DropdownMenuItem | 23.1 kB (−1 B) · 6.6 kB CSS (0) | — | — · — · — |
| Field | 59.3 kB (−1 B) · 7.3 kB CSS (0) | — | — · — · — |
| RadioListItem | 71.9 kB (−1 B) · 10.4 kB CSS (0) | — | — · — · — |
| SideNav | 120.6 kB (−1 B) · 12.2 kB CSS (0) | — | — · — · — |
| Stepper | 66.5 kB (−1 B) · 10.9 kB CSS (0) | — | — · — · — |
| TableCell | 118.7 kB (−1 B) · 18.8 kB CSS (0) | — | — · — · — |
| Timestamp | 35.8 kB (−1 B) · 11.0 kB CSS (0) | — | — · — · — |
| CheckboxInput | 68.8 kB (−2 B) · 10.1 kB CSS (0) | — | — · — · — |
| MoreMenu | 104.4 kB (−2 B) · 18.5 kB CSS (0) | — | — · — · — |
| RadioList | 60.6 kB (−2 B) · 7.3 kB CSS (0) | — | — · — · — |
| TabMenu | 78.6 kB (−2 B) · 11.9 kB CSS (0) | — | — · — · — |
| ToggleButton | 91.8 kB (−2 B) · 10.9 kB CSS (0) | — | — · — · — |
| Banner | 66.9 kB (−3 B) · 11.3 kB CSS (0) | — | — · — · — |
| CheckIndicator | 8.4 kB (−3 B) · 681 B CSS (0) | — | — · — · — |
| SideNavCollapseButton | 65.7 kB (−3 B) · 10.8 kB CSS (0) | — | — · — · — |
| IconButton | 64.9 kB (−4 B) · 10.8 kB CSS (0) | — | — · — · — |
| Tokenizer | 103.5 kB (−4 B) · 20.0 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 112.7 kB (−4 B) · 773 B CSS (0) | — | — · — · — |
| PowerSearch | 306.1 kB (−6 B) · 25.3 kB CSS (0) | — | — · — · — |
| CodeBlock | 79.9 kB (−152 B) · 12.1 kB CSS (0) | — | — · — · — |
| Markdown | 198.5 kB (−152 B) · 21.5 kB CSS (0) | — | — · — · — |
| ContextMenuItem | 33.5 kB (−153 B) · 6.8 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 360.5 kB (−157 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/Comments | 367.3 kB (−168 B) · 2.5 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 158.8 kB (−179 B) · 1.9 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.52 MB packed (+281 B); no new dependencies.
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, so a maintainer needs to add the ci:run label for the required checks to run.
The change restores the icon spec's rule that a malformed slot field is ignored field by field with a development-only warning (AST-087 FR20 and DEC-8): the new tests fail against the current resolver with a BigInt serialization error and pass with this change, and the public API is unchanged. No changes requested.
Claims and files checked
- Claim: malformed slot values no longer throw while the warning is formatted. Verified:
globalIconRegistry.tsx:481-486; three tests fail on the base and pass here. - Claim: invalid fields keep the component's value and valid sibling fields still apply. Verified:
componentIcons.test.tsx:177-190. - Claim: production skips diagnostic formatting. Verified:
globalIconRegistry.tsx:478-480and the production test atcomponentIcons.test.tsx:197-219. - Claim: before this change the throw happens during render, in production too. Verified: the production test fails on the base; the render path calls the resolver directly (
useIcon.ts:48-55). - Claim: ordinary warning text and deduplication are unchanged. Verified: each message rebuilds the old text exactly; the existing one-warning test table passes.
- Claim: errors thrown by a theme's resolver still propagate. Verified: the resolver call at
globalIconRegistry.tsx:571is outside thetry. - Claim: the module-local
processdeclaration keeps source consumers free of Node types. Verified: built declarations are unchanged and the ejected-source tests pass. - Claim: no public API, default, documentation or story change. Verified: the built package surfaces match the merge base.
- Claim: the Icon, theme and dev-warning suites pass (34 files, 1,921 tests). Verified: same counts.
- Claim: the ejected-source tests pass (9 files, 1 skipped; 17 tests, 1 skipped). Verified: same counts.
- Claim: strict lint has no errors, the build passes and the scoped type check is clean. Verified: strict eslint over the repository reports 0 errors and 237 warnings, and the Core and theme builds and the Core type check pass.
- Claim: a minified production bundle shows no warnings or serialization. Not reproduced, because that harness is not in the pull request; the production unit test checks the same property.
- Claim: browser recordings show the fallback and a working button. Consistent with the tests and with a browser check of the same scenario on CodeBlock.
- Claim: formatting and whitespace checks pass. Verified.
- File
.changeset/fix-malformed-icon-slot-diagnostics.md: clear. - File
packages/core/src/Icon/componentIcons.test.tsx: clear. - File
packages/core/src/Icon/globalIconRegistry.tsx: clear.
|
/approve-spec e5b2579 |
|
/approve-spec 73ef047 |
There was a problem hiding this comment.
Approved pending CI: CI is still running on this head, and the test-node (1/5) shard hit its 15-minute job limit during the theme-family check, after all of its node test files passed, so it needs a re-run.
The change restores the icon spec's rule that a malformed component icon slot field is ignored field by field with a development-only warning (AST-087 FR20 and DEC-8): the new tests fail against the current resolver with a BigInt serialization error and pass with this change, a CodeBlock under a BigInt or circular slot value now renders its copy button instead of throwing, and the public API is unchanged. No changes requested.
Claims and files checked
- Claim: malformed slot values no longer throw while the warning is formatted. Verified:
globalIconRegistry.tsx:481-486; three tests fail on the base and pass here. - Claim: invalid fields keep the component's value and valid sibling fields still apply. Verified:
componentIcons.test.tsx:177-189. - Claim: production skips diagnostic formatting. Verified:
globalIconRegistry.tsx:478-480and the production test atcomponentIcons.test.tsx:196-219, wheretoJSONis never called. - Claim: before this change the throw happens during rendering, in production too. Verified: the production test fails on the base, and the render path calls the resolver directly (
useIcon.ts:48-55). - Claim: ordinary warning text and deduplication are unchanged. Verified: each message rebuilds the old text exactly, and the existing one-warning tests pass.
- Claim: errors thrown by a theme's slot function still propagate. Verified: the call at
globalIconRegistry.tsx:571is outside thetry. - Claim: the module-local
processdeclaration keeps source consumers free of Node types. Verified: the built declarations are unchanged, and the process-env type test and the ejected-source tests pass. - Claim: no public API, default, documentation or story change, and no common error icon. Verified: the built package surfaces match the base, and the fallback stays the component's own.
- Claim: the Icon, theme and dev-warning suites pass. Verified: 35 files and 1,944 tests pass on this head (34 files and 1,921 tests before the main branch was merged in).
- Claim: the ejected-source tests pass (9 files, 1 skipped; 17 tests, 1 skipped). Verified: same counts.
- Claim: the build passes, strict lint has no errors (237 warnings) and the type check is clean. Verified: the Core and theme builds and the Core type check pass, and strict lint over the repository reports 0 errors and 237 warnings.
- Claim: a minified production bundle shows no warnings or serialization. Not reproduced, because that harness is not part of the pull request; the production unit test checks the same property.
- Claim: browser recordings show the fallback and a working button. Consistent with a browser check of CodeBlock under the same malformed values.
- Claim: formatting checks pass. Verified with Prettier.
- File
.changeset/fix-malformed-icon-slot-diagnostics.md: clear. - File
packages/core/src/Icon/componentIcons.test.tsx: clear. - File
packages/core/src/Icon/globalIconRegistry.tsx: clear.
User impact
When a theme's component icon slot returns a malformed value containing a BigInt or a circular reference, icon resolution throws during rendering instead of keeping the component's fallback. The exception also occurs in production, even though production emits no warning. A bad icon field can therefore replace the surrounding screen with an error boundary's fallback rather than simply keeping the original glyph.
Problem and solution fit
The validator interpolates
JSON.stringifyinto its diagnostic before the development-only logger runs. Serialization can throw before field-wise fallback finishes; making the logger silent does not prevent that work.The existing private warning helper now receives the offending value, skips formatting in production, and catches serialization failures in development. Ordinary diagnostic text and warning deduplication keep their existing paths. The resolver call itself remains outside the catch, so errors thrown by a theme's resolver still propagate.
Expected behavior and authority
AST-087 FR20 and DEC-8 require malformed fields to be treated as missing, with a development-only warning. FR13 requires field-wise fallback: valid sibling fields still apply. The component slot precedence contract assigns that fallback to the component; this change does not introduce a common error icon.
Smallest restoration
One private diagnostic helper and its call sites, two explicit regression cases in the existing slot test file, a stronger existing production test, and a Core patch changeset. A module-local, erased declaration keeps source consumers independent of Node types. Existing malformed-value coverage supplies the ordinary fallback and deduplication checks. No public API, compatibility field, component default, consumer documentation, or shipped story changes.
Evidence
{icon: 1n, variant: 'filled', size: 'lg'}throws while formatting the warning, so the fixture's button does not render. A circular icon field has the same outcome.copyfallback while retainingfilledandlg; the real Button and Icon render and the button's click count advances.clockrequest renders and the button works before and after malformed input, in both implementations.The recordings use the same recording-only Storybook fixture and 1100 × 780 viewport in Chromium 149. AS-IS loads the exact base resolver from
a4fe0154fb; TO-BE loads the proposed resolver. Both feed the resolved request into the same real Button and Icon. An error boundary only keeps the demonstration visible after the actual AS-IS exception. The fixture and media are not part of the source diff.AS-IS
astryx-icon-slot-as-is.mp4
TO-BE
astryx-icon-slot-to-be.mp4
Scope
Components: shared Icon component-slot diagnostics.
Testing
pnpm exec vitest run --project ui packages/core/src/Icon packages/core/src/theme packages/core/src/utils/devWarning.test.ts --maxWorkers=2— 34 files / 1,921 tests passed.pnpm lint:strict— 0 errors (237 warnings).pnpm build— workspace build passed.pnpm exec vitest run --project node packages/cli/test/swizzle-proof --maxWorkers=2— 9 files passed / 1 skipped; 17 tests passed / 1 skipped, including ejected source consumers.git diff --check.