Skip to content
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

fix(core): better Zod validation error messages #5745

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

thsig
Copy link
Collaborator

@thsig thsig commented Feb 19, 2024

What this PR does / why we need it:

Before this fix, we were simply passing through the default error messages generated by Zod when validation failed. This resulted in JSON-like error messages when a Zod schema validation error happened.

This was fixed by detecting Joi VS Zod validation errors, and adding a little rendering logic for Zod errors to improve the output.

Which issue(s) this PR fixes:

Fixes #5446.

Special notes for your reviewer:

Before this fix, introducing an exec Test with a missing spec.command would result in an error message like this:

Screenshot 2024-02-19 at 12 06 18

After this fix:

Screenshot 2024-02-19 at 12 05 33

Before this fix, we were simply passing through the default error
messages generated by Zod when validation failed. This resulted in
JSON-like error messages when a Zod schema validation error happened.

This was fixed by detecting Joi VS Zod validation errors, and adding
a little rendering logic for Zod errors to improve the output.
Remove duplicate type `ObjectPath`.
Copy link
Collaborator

@vvagaytsev vvagaytsev left a comment

Choose a reason for hiding this comment

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

LGTM! 👍 Thank you!

@vvagaytsev vvagaytsev added this pull request to the merge queue Feb 19, 2024
Merged via the queue into main with commit dc49f10 Feb 19, 2024
44 checks passed
@vvagaytsev vvagaytsev deleted the better-zod-validation-errors branch February 19, 2024 14:57
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.

0.13: [Bug]: Spec validation error message is printed with JSON encoding
2 participants