Skip to content

fix(error-reporting): silence search-query parse 400s (CLI-FA)#1151

Merged
BYK merged 2 commits into
mainfrom
byk/fix/silence-query-parse-400
Jun 26, 2026
Merged

fix(error-reporting): silence search-query parse 400s (CLI-FA)#1151
BYK merged 2 commits into
mainfrom
byk/fix/silence-query-parse-400

Conversation

@BYK

@BYK BYK commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

When a user passes invalid --query syntax, the Sentry search endpoint returns
a 400 whose detail begins with "Error parsing search query: ...". Examples
seen in production:

  • is:403invalid status value of '403'
  • lastSeen:>=-24hInvalid date: >=-24h. Expected +/-duration
  • empty status:Empty string after 'status:'
  • issue.id:EVA-BCHInvalid number

classifySilenced captures all 400s by default (treating them as
CLI-constructed malformed requests), so these user query-syntax mistakes were
reported as crash reports — making CLI-FA
one of the highest-volume issues: ~450 users, still firing on 0.38.0 across
issue list, explore, and trace list.

Fix

Add a narrow exception in classifySilenced: a 400 whose server detail
reports an unparseable search query (Error parsing search query) is a user
input error, not a CLI bug. The API already returns an actionable message, so
silence it and preserve volume via the cli.error.silenced metric. All other
400s remain captured
(the "400 = CLI bug" default is unchanged).

  • The discriminator is the server's own parser message — the API explicitly
    states it could not parse the user-supplied query, which a CLI-constructed
    bad request would not produce.
  • The match is a substring check, robust to the CLI re-wrapping list errors
    (enrichIssueListError prepends the original server detail before adding
    hints).

Test plan

  • New isSearchQueryParseError helper (exported for testing).
  • Tests: raw query-parse 400 → api_query_error; wrapped issue-list 400 (detail
    prepended) → api_query_error; non-query 400 → still captured (null);
    422 with the marker → not treated as a query 400 (status must be 400).
  • vitest run test/lib/error-reporting.test.ts → 80 passed
  • vitest run test/lib/telemetry.test.ts (classifySilenced consumer) → 107 passed
  • biome check clean on changed files

Fixes CLI-FA

When a user passes invalid `--query` syntax (e.g. `is:403`,
`lastSeen:>=-24h`, an empty `status:`), the Sentry search endpoint
returns a 400 whose detail begins with "Error parsing search query: ...".
classifySilenced captures all 400s by default (treating them as
CLI-constructed malformed requests), so these user query-syntax mistakes
were reported as crash reports — making CLI-FA one of the highest-volume
issues (~450 users across issue/explore/trace list).

Add a narrow exception: a 400 whose server detail reports an unparseable
search query is a user input error, not a CLI bug. The API already
returns an actionable message, so silence it (preserving volume via the
cli.error.silenced metric). All other 400s remain captured.

The match is a substring check on the server's own parser message, which
is robust to the CLI re-wrapping list errors (enrichIssueListError
prepends the original detail).
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 2026

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-1151/

Built to branch gh-pages at 2026-06-26 21:21 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/lib/error-reporting.ts
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 5131 uncovered lines.
✅ Project coverage is 81.47%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.46%    81.47%    +0.01%
==========================================
  Files          397       397         —
  Lines        27686     27694        +8
  Branches     17972     17983       +11
==========================================
+ Hits         22555     22563        +8
- Misses        5131      5131         —
- Partials      1861      1861         —

Generated by Codecov Action

…erApiError

Addresses Seer review: the upgrade-nudge logic (isUserError →
getErrorUpdateNotification) and span-attribution logic (isUserApiError)
only treated status > 400 as user errors, so a silenced search-query
parse 400 would still trigger a misleading "Upgrading may resolve this"
banner and be mis-attributed.

Move isSearchQueryParseError into errors.ts as the single source of truth
and use it from all three 4xx classifiers (classifySilenced, isUserError,
isUserApiError) so they agree on query-parse 400s.
@BYK BYK merged commit 70c6911 into main Jun 26, 2026
30 checks passed
@BYK BYK deleted the byk/fix/silence-query-parse-400 branch June 26, 2026 21:29
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.

1 participant