This repository was archived by the owner on Oct 23, 2026. It is now read-only.
Repository navigation
fix(error-reporting): silence search-query parse 400s (CLI-FA) - #1151
Merged
Merged
Conversation
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).
Contributor
|
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 5131 uncovered lines. 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
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.
5 tasks
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
When a user passes invalid
--querysyntax, the Sentry search endpoint returnsa 400 whose detail begins with
"Error parsing search query: ...". Examplesseen in production:
is:403→ invalid status value of '403'lastSeen:>=-24h→ Invalid date: >=-24h. Expected +/-durationstatus:→ Empty string after 'status:'issue.id:EVA-BCH→ Invalid numberclassifySilencedcaptures all 400s by default (treating them asCLI-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, andtrace list.Fix
Add a narrow exception in
classifySilenced: a 400 whose server detailreports an unparseable search query (
Error parsing search query) is a userinput error, not a CLI bug. The API already returns an actionable message, so
silence it and preserve volume via the
cli.error.silencedmetric. All other400s remain captured (the "400 = CLI bug" default is unchanged).
states it could not parse the user-supplied query, which a CLI-constructed
bad request would not produce.
(
enrichIssueListErrorprepends the original server detail before addinghints).
Test plan
isSearchQueryParseErrorhelper (exported for testing).api_query_error; wrapped issue-list 400 (detailprepended) →
api_query_error; non-query 400 → still captured (null);422with the marker → not treated as a query 400 (status must be 400).vitest run test/lib/error-reporting.test.ts→ 80 passedvitest run test/lib/telemetry.test.ts(classifySilenced consumer) → 107 passedbiome checkclean on changed filesFixes CLI-FA