fix(error-reporting): silence ValidationError in classifySilenced#1235
Open
sentry[bot] wants to merge 1 commit into
Open
fix(error-reporting): silence ValidationError in classifySilenced#1235sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
Contributor
|
Comment on lines
+95
to
+97
| if (error instanceof ValidationError) { | ||
| return "validation_error"; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Bug: The change to silence ValidationError in classifySilenced will cause multiple existing tests to fail, as they expect these errors to be reported.
Severity: HIGH
Suggested Fix
The tests that verify the behavior of ValidationError need to be updated to align with the new intention of silencing these errors. Either remove the ValidationError case from the test that expects it not to be silenced, or update the integration tests to no longer expect Sentry.withScope to be called for ValidationError. Alternatively, if ValidationError should not be silenced, revert this change.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/lib/error-reporting.ts#L95-L97
Potential issue: The modification in `classifySilenced` to handle `ValidationError` will
cause existing tests to fail. A unit test expects `classifySilenced(new
ValidationError(...))` to return `null`, but it will now return `"validation_error"`.
Additionally, several integration tests rely on `reportCliError` processing
`ValidationError` instances and invoking `Sentry.withScope`. Since the error is now
silenced, `reportCliError` will return early, and these tests, which expect Sentry scope
tags to be set, will fail because the test files were not updated to reflect this new
behavior.
Also affects:
test/lib/error-reporting.test.ts:321~329
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Previously,
ValidationErrors, such as those arising from invalid user input for flags like--action-matchinsentry alert issues create, were being reported to Sentry as issues.These errors represent user input mistakes and should be silenced to prevent noise in Sentry. The root cause was that
classifySilenced()insrc/lib/error-reporting.tsdid not explicitly handleValidationError, causing it to fall through and be captured.This change updates
src/lib/error-reporting.tsto:"validation_error"to theSilenceReasontype.classifySilenced()to return"validation_error"when aninstanceof ValidationErroris encountered.This ensures that
ValidationErrors are now correctly silenced and tracked via thecli.error.silencedmetric, rather than being sent as Sentry issues.Fixes CLI-20M
Comment
@sentry <feedback>on this PR to have Autofix iterate on the changes.