You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(errors): surface user search-query 400s as ValidationError, keep CLI-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.
0 commit comments