Show the Zoekt message for a rejected code search query
What does this MR do and why?
Fixes console errors in feature specs when Zoekt rejects a search query. The changes distinguish between rejected queries (bad syntax or invalid regex) and server failures, so the frontend can handle each appropriately.
Before this change:
- All Zoekt failures set the same error type, so the frontend could not distinguish a bad query from a server outage.
- The app logged every failure with
logError(aconsole.error). - The error state showed a generic message and did not include the Zoekt rejection reason.
After this change:
- Backend differentiates: 4xx responses (bad request) get
InvalidQueryError; 5xx responses (server failure) getBaseError. - Frontend reads the error type and message from the GraphQL response.
- Bad queries show the Zoekt message (e.g. "error parsing regexp: missing argument to repetition operator") with syntax help.
- Bad queries are no longer logged or reported to Sentry.
- Server failures still log and report.
References
- Part of section D of #628901 (console errors in feature specs)
- Console check and baseline allowlist MR that surfaced it: !255207 (closed)
- Reveal pipeline jobs showing the errors: https://gitlab.com/gitlab-org/gitlab/-/jobs/16462296389 and https://gitlab.com/gitlab-org/gitlab/-/jobs/16462296386
Screenshots or screen recordings
The error empty state now shows the Zoekt message above the "To resolve the problem, check the query syntax and try again. What is the supported syntax" line. For example, if you search for the invalid regex *, the error state displays "error parsing regexp: missing argument to repetition operator" followed by the syntax help. A screenshot will be added after the pipeline passes.
How to set up and validate locally
- Run
yarn jest spec/frontend/search. - In a GDK with Zoekt enabled, open a project code search, turn on regular expression mode, and search for
*. - The results area shows "A problem has occurred" with the Zoekt message and the syntax link.
- The browser console shows no
[gitlab] Error: bad requestline. - Stop Zoekt and search again. The connection error state still appears and the failure is still logged.
The Zoekt RSpec unit specs need a running Zoekt instance, which the local environment did not have, so they were not run locally. The MR pipeline runs them.
MR acceptance checklist
This MR was evaluated against the acceptance checklist.