Skip to content

fix(Icon): keep malformed slot diagnostics from interrupting rendering - #11502

Merged
cixzhang merged 2 commits into
meta:mainfrom
korkt-kim:korkt-kim/ast087-malformed-slot-output
Nov 13, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
korkt-kim:korkt-kim/ast087-malformed-slot-output

Conversation

@korkt-kim

Copy link
Copy Markdown
Contributor

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.stringify into 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

  • Before: {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.
  • After: the component keeps its copy fallback while retaining filled and lg; the real Button and Icon render and the button's click count advances.
  • Representative unchanged path: a valid clock request renders and the button works before and after malformed input, in both implementations.
  • Regression proof: the two new tests and the updated production test reproduce serialization exceptions with the base resolver and pass with this change. The cases cover partial requests, invalid whole results, and production skipping diagnostic serialization without duplicating a mode/input matrix.

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.

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

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.
  • Minified production source bundle — 13 cases passed, no warnings and no diagnostic serialization.
  • Scoped TypeScript check — no diagnostics.
  • 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.
  • Real-browser valid, BigInt, circular, recovery, and click paths shown above.
  • Prettier and git diff --check.

@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 13, 2026 4:25pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 13, 2026
@astracat-bot

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 13, 2026, 4:38 PM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 73ef047

Storybook · Sandbox · built from this PR's head

Modified components

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

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-480 and the production test at componentIcons.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:571 is outside the try.
  • Claim: the module-local process declaration 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.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec e5b2579

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 13, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 73ef047

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-480 and the production test at componentIcons.test.tsx:196-219, where toJSON is 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:571 is outside the try.
  • Claim: the module-local process declaration 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.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 13, 2026 17:09
@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 17:09
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 13, 2026
@cixzhang
cixzhang merged commit b9ef399 into meta:main Nov 13, 2026
151 of 153 checks passed
@github-actions
github-actions Bot deleted the korkt-kim/ast087-malformed-slot-output branch November 14, 2026 12:35

This branch was successfully deployed

1 active deployment
Preview — 73ef047b Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants