fix(error-reporting): Silence ValidationError#1232
Open
sentry[bot] wants to merge 1 commit into
Open
Conversation
Contributor
|
Comment on lines
+106
to
+108
| if (error instanceof ValidationError) { | ||
| return "validation_error"; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Bug: The change silences all ValidationError instances, but some are used for internal logic errors (like exhaustiveness checks), not just user input. This will hide CLI bugs from Sentry.
Severity: MEDIUM
Suggested Fix
Instead of silencing the entire ValidationError class, the silencing logic should be more specific. Consider silencing only ValidationError instances that are known to be from user input, perhaps by checking for a specific field or message pattern, or by only silencing them when thrown from specific validation functions. This would allow internal errors to still be captured.
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#L106-L108
Potential issue: The change in `classifySilenced` now silences all `ValidationError`
instances. However, the codebase uses `ValidationError` not only for user input errors
but also for internal CLI defects. For example, exhaustiveness checks in
`src/lib/trace-target.ts` throw `ValidationError` to catch unhandled cases in
discriminated unions. Silencing these errors means that genuine bugs in the CLI's logic
will no longer be reported to Sentry, hindering debugging and maintenance. An existing
test explicitly asserts that `ValidationError` should not be silenced, which will fail
with this change.
Also affects:
src/lib/trace-target.tssrc/commands/trial/start.ts
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.
Currently,
ValidationErrors, which typically indicate malformed user input (e.g., invalid JSON for--conditionflags), are not explicitly silenced in the CLI's error reporting mechanism. This leads to these user-facing errors being captured and sent to Sentry as if they were internal bugs.This PR addresses the issue by:
"validation_error"to theSilenceReasontype insrc/lib/error-reporting.ts.classifySilenced()to recognizeValidationErrorand return"validation_error", thereby preventing these errors from being reported to Sentry.This ensures that Sentry reports are focused on actual CLI defects, while user input errors are handled gracefully without generating unnecessary Sentry events.
Fixes CLI-1ZD
Comment
@sentry <feedback>on this PR to have Autofix iterate on the changes.