-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Zod error messages and user config error messages #12634
Conversation
🦋 Changeset detectedLatest commit: 2170904 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #12634 will not alter performanceComparing Summary
|
I think the error map is exported and used in |
Yes! Didn't know it was available to external packages. After this PR it will be exactly the same as Starlight's so we could definitely reuse it. |
const errorList = err.issues.map( | ||
(issue) => ` ! ${bold(issue.path.join('.'))} ${red(issue.message + '.')}`, | ||
const errorList = err.issues.map((issue) => | ||
`! ${renderErrorMarkdown(issue.message, 'cli')}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My highly-featured markdown renderer keep seeing usage 🫡
Changes
Upstreams improvements to the Zod error map that we made in Starlight. We initially copied Astro’s error map and then iterated on it. It’s still similar, just with better handling for complex types like unions, and more consistent formatting (e.g. if you look at the changed tests you’ll see we’d report errors where some stuff was wrapped with backticks and other stuff wasn’t within the same error message and that that is now fixed).
Updates error handling for user config parse errors to use the error map. With the v5 release, we’re seeing a fair amount of the rather confusing
output Invalid input
error when people leaveoutput: "hybrid"
in their config and this aims to improve that.Fixes a broken docs link in one of our error messages.
Example
Example error message with this change when adding
output: 'hybrid', experimental: { contentLayer: true }
to an astro.config file:Currently
After this PR
Testing
astro dev
in the blog example using invalid configurations to test output.Docs
n/a — error message improvements only