Skip to content

fix(error-reporting): silence ValidationError from Sentry#1251

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/cli-296-validation-error-silence
Open

fix(error-reporting): silence ValidationError from Sentry#1251
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/cli-296-validation-error-silence

Conversation

@sentry

@sentry sentry Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This PR addresses CLI-296 by ensuring ValidationError instances are silenced and not reported to Sentry.

Problem:
ValidationErrors, which indicate invalid user input (e.g., incompatible command-line flags like --follow with an absolute date range), were being reported to Sentry. These are user-facing errors that should be presented to the user as usage messages, not treated as internal CLI bugs.

Root Cause:
The classifySilenced function in src/lib/error-reporting.ts lacked a specific case to identify and silence ValidationError instances. As a result, these errors fell through the silencing logic and were captured by Sentry.

Solution:

  1. Added 'validation_error' to the SilenceReason union type in src/lib/error-reporting.ts.
  2. Introduced a new if (error instanceof ValidationError) check within classifySilenced to return 'validation_error', thereby silencing these errors.
  3. Updated the corresponding test in test/lib/error-reporting.test.ts to reflect that ValidationErrors are now correctly silenced.
  4. Added a comment to classifySilenced explaining the rationale for silencing ValidationErrors.

Fixes CLI-296

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@linear-code

linear-code Bot commented Jul 15, 2026

Copy link
Copy Markdown

CLI-296

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1251/

Built to branch gh-pages at 2026-07-15 10:43 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a8418f9. Configure here.

"validation_error"
);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Broken ValidationError tagging tests

Medium Severity

classifySilenced now returns early for ValidationError, so reportCliError never calls withScope or sets grouping tags. The reportCliError integration tests still use capturedScopeTags with ValidationError and assert cli_error.class / cli_error.kind, which will fail because those tags stay empty.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a8418f9. Configure here.

Comment on lines 298 to +304
expect(classifySilenced(err)).toBeNull();
});

test("silences ValidationError (user input mistake)", () => {
expect(classifySilenced(new ValidationError("bad"))).toBe(
"validation_error"
);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bug: Integration tests for ValidationError will fail because they were not updated to reflect that this error is now silenced in reportCliError, which now returns early before calling Sentry.withScope.
Severity: LOW

Suggested Fix

Update the four integration tests for ValidationError in test/lib/error-reporting.test.ts (starting around line 479) to align with the new behavior. These tests should either be removed or modified to assert that ValidationError is correctly silenced and that Sentry.withScope is not called.

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: test/lib/error-reporting.test.ts#L298-L304

Potential issue: The function `reportCliError` was modified to silence `ValidationError`
instances by returning early. However, four integration tests in
`test/lib/error-reporting.test.ts` were not updated to reflect this new behavior. These
tests mock `Sentry.withScope` and expect it to be called to capture error tags. Because
`reportCliError` now returns early for a `ValidationError`, `Sentry.withScope` is never
invoked. Consequently, the expected tags are not set, and assertions within these tests
will fail, breaking the test suite.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants