fix: improve error message for invalid icon imports#4062
Open
fix: improve error message for invalid icon imports#4062
Conversation
Preview deployments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 captureerror, 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'scaptureResultpicks this up and surfaces the message in the error document.Before

After
