Skip to content

fix: improve error message for invalid icon imports#4062

Open
FadhlanR wants to merge 1 commit intomainfrom
cs-10201-bad-import-will-produce-an-unhelpful-message
Open

fix: improve error message for invalid icon imports#4062
FadhlanR wants to merge 1 commit intomainfrom
cs-10201-bad-import-will-produce-an-unhelpful-message

Conversation

@FadhlanR
Copy link
Contributor

@FadhlanR FadhlanR commented Feb 25, 2026

Problem

When a card definition has a static icon that is a bad named import (e.g. import { NonExistent } from '@cardstack/boxel-icons/non-existing-path/nope'), JavaScript silently resolves it to undefined. This caused the prerenderer to produce a cryptic [data-prerender] has no child element to capture error, giving developers or ai-bot no actionable information.

Fix

Added a guard in the render/icon route's model() hook that checks whether cardTypeIcon() resolved to a valid component. If not, it throws a descriptive error: static icon is undefined — check that the import resolves to a valid icon component. Because Ember is still intact at this point, the error propagates via the parent render route's error action hook into the render.error route, which renders a [data-prerender-error] element. The prerenderer's captureResult picks this up and surfaces the message in the error document.

Before
Screenshot 2026-02-26 at 13 15 32

After
Screenshot 2026-02-26 at 13 06 31

@github-actions
Copy link

Preview deployments

@github-actions
Copy link

Host Test Results

    1 files  ±0      1 suites  ±0   1h 35m 26s ⏱️ - 3m 57s
1 878 tests ±0  1 863 ✅ ±0  15 💤 ±0  0 ❌ ±0 
1 893 runs  ±0  1 878 ✅ ±0  15 💤 ±0  0 ❌ ±0 

Results for commit 0827549. ± Comparison against base commit c2e3fb9.

@FadhlanR FadhlanR marked this pull request as ready for review February 26, 2026 06:16
@FadhlanR FadhlanR requested review from a team and habdelra February 26, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant