Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

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

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:403 → invalid status value of '403'
  • lastSeen:>=-24h → Invalid date: >=-24h. Expected +/-duration
  • empty status: → Empty string after 'status:'
  • issue.id:EVA-BCH → Invalid 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 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 Resolved
@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
BYK added a commit that referenced this pull request Jul 14, 2026
…LI-built 400s reported (#1154)

## Why

Follow-up to #1151 based on review feedback: **silencing every
search-query 400 papers over a real bug class.**

HTTP 400 means the server rejected our request as malformed. That has
two distinct causes, only distinguishable at the command boundary (where
`flags.query` is in scope):

1. **The user typed an invalid `--query`** → a user input mistake.
2. **The CLI built an invalid query itself** (no user `--query`) → a
genuine CLI defect.

PR #1151 special-cased `isSearchQueryParseError()` in all three
classifiers (`classifySilenced`, `isUserError`, `isUserApiError`), which
silenced **both** — so CLI-authored bad queries became invisible.

## What changed

- **New `toSearchQueryError(error, userQuery, extraSuggestions?)`** in
`src/lib/errors.ts`: converts a parse-400 into a clean, actionable
`ValidationError` **only when the user supplied `--query`**. When
there's no user `--query`, the original `ApiError(400)` is returned
untouched so it stays reported to Sentry as the CLI bug it is.
- Wired in at the three command boundaries that accept `--query`: `issue
list` (both the single- and multi-project 400 paths), `explore`, and
`trace list`.
- **Removed** the `isSearchQueryParseError` special-case from
`classifySilenced` (+ dropped the `api_query_error` `SilenceReason`),
`isUserError`, and `isUserApiError`. A raw `ApiError(400)` is now always
treated as a reported CLI bug.

## Result

- User query typos → clean `ValidationError` with the server detail +
search-syntax help (correct exit code, no "CLI bug" upgrade nudge).
- CLI-constructed bad queries → still reported, so we can actually find
and fix them.

## Note

A user-query `ValidationError` is still surfaced to the user and (like
other `ValidationError`s) reaches Sentry — that volume is now a useful
signal for client-side query-linting UX rather than noise mislabeled as
a 400 crash. Happy to silence query `ValidationError`s separately if
preferred.

## Tests

- `toSearchQueryError` unit tests (convert vs passthrough, suggestions,
non-ApiError).
- `issue list` integration tests: user `--query` → `ValidationError`; no
`--query` → reported `ApiError(400)`.
- Updated `classifySilenced` / `isUserError` / `isUserApiError` tests to
assert search-query 400s are no longer silenced.
- Full unit suite for touched files green; lint + typecheck clean.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant