-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(core): Improve error formatting in ZodErrors integration #15111
feat(core): Improve error formatting in ZodErrors integration #15111
Conversation
"sideEffects": false | ||
"sideEffects": false, | ||
"devDependencies": { | ||
"zod": "^3.24.1" |
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.
Wasn't sure if adding deps was okay, but it made adding tests a lot easier
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.
This is fine for testing
- Include full key path rather than the top level key in title - Improve message for validation issues with no path - Add option to include extended issue information as an attachment
faa1518
to
06232f3
Compare
@jahands thanks for the PR! could you share a link to a sentry event / screenshot of a sentry event that shows the changes from this PR? |
@AbhiPrasad done! |
Assigning myself so I can help review and merge this in! On my todo to review tomorrow morning :) |
"sideEffects": false | ||
"sideEffects": false, | ||
"devDependencies": { | ||
"zod": "^3.24.1" |
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.
This is fine for testing
* Takes ZodError issue path array and returns a flattened version as a string. | ||
* This makes it easier to display paths within a Sentry error message. | ||
* | ||
* Array indexes are normalized to reduce duplicate entries |
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.
I'm not sure we want to duplicate entries here, I think [0].foo.[1].bar
is more valuable than <array>.foo.<array>.bar
, and we want to make sure that different array entries will lead to different issues.
What do you think?
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.
This is only applied to the issue message, not event.extra
or attachments which still include all unique issues with the full path including indexes.
In practice, we found that having the indexes in the message is more noise than helpful for understanding the issue at a glance, which was the primary motivation for me making this improvement in our internal fork.
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.
Sounds good to me, let's keep what is here then
Hmm tests seem to be failing because the attachment doesn't match the issues being sent anymore. I wonder why 🤔
|
Oh I see, we need to skip slicing the list of issues before flattening if save attachment is enabled so that the full list is included in the attachment. Will fix |
@AbhiPrasad fixed that bug, tests pass for me locally now |
This PR adds the external contributor to the CHANGELOG.md file, so that they are credited for their contribution. See #15111 Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
- Include full key path rather than the top level key in title - Improve message for validation issues with no path - Add option to include extended issue information as an attachment
- Include full key path rather than the top level key in title - Improve message for validation issues with no path - Add option to include extended issue information as an attachment
- Adds improvements based on feedback I got while PR'ing this to sentry-javascript: getsentry/sentry-javascript#15111 - Exports zodErrorsIntegration in the root index.ts (missed this in the original PR)
Background
I tried using this integration, but found the error format in Sentry to be lacking.
I added tests to demonstrate how this will format issues.
Screenshots
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint
) & (yarn test
).