Skip to content

fix: tell a failed search apart from one with no results - #2366

Closed
uuzzrm wants to merge 1 commit into
felladrin:mainfrom
uuzzrm:fix/search-failure-vs-empty-results
Closed

fix: tell a failed search apart from one with no results#2366
uuzzrm wants to merge 1 commit into
felladrin:mainfrom
uuzzrm:fix/search-failure-vs-empty-results

Conversation

@uuzzrm

@uuzzrm uuzzrm commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Closes #2336.

What changed

fetchSearXNG used to catch every failure and return [], so when SearXNG was down the client got exactly the same response as a search that simply had no results. Both cases showed the red "Search failed" alert with a retry button — someone searching for something genuinely obscure was told the search broke, and a real outage looked like an ordinary empty search.

Now:

  • Server: upstream failures throw SearXNGSearchError, and /search/text / /search/images answer 503 for them. A genuinely empty result set still comes back as 200 with [].
  • Client: startTextSearch / startImageSearch no longer derive failed from length === 0. An outage leaves the state failed; an empty result set leaves it completed, which renders the already-existing "No results found" alert.
  • The keyword fallback in startTextSearch only runs for real empty result sets now, so an outage doesn't fire a second request.

Why a status code

The client already treats a non-OK response as a failure in searchService.performSearch, so a 503 needs no new client plumbing — the empty array keeps meaning exactly one thing.

Tests & docs

  • Updated the failure-injection matrix in docs/failure-injection.md and removed the Known Limitations entry that pinned the old behavior.
  • server/webSearchService.test.ts now asserts the outage rejects while a zero-result search resolves to [].
  • server/searchEndpointServerHook.test.ts asserts 503 for text and image searches when SearXNG is down, and 200 with [] for a no-result search.
  • client/modules/textGeneration.degradation.test.ts covers: empty result set → completed, outage → failed with no fallback, plus the image-search equivalents.
  • client/modules/search.test.ts updated for searchText / searchImages propagating failures instead of collapsing them into [].

Full suite is green (vitest run), tsc passes, and Biome/knip/jscpd report no issues.

fetchSearXNG used to swallow every failure and return [], so an outage and a
genuinely empty result set reached the client as the same response. A query with
no results showed the red failure alert, and a real SearXNG outage looked like
an ordinary empty search.

Upstream failures now throw SearXNGSearchError, the /search endpoints answer
503 for them, and the client maps that to the failed state. Empty result sets
still come back as 200 with [] and render the existing empty-state alert.
The keyword fallback only fires for real empty result sets now, so an outage
does not trigger a second request.
@uuzzrm
uuzzrm force-pushed the fix/search-failure-vs-empty-results branch from 2b1e835 to 5da39a6 Compare August 14, 2026 22:58
@uuzzrm uuzzrm closed this Aug 15, 2026
@uuzzrm uuzzrm reopened this Aug 15, 2026
@uuzzrm uuzzrm closed this Aug 15, 2026
@uuzzrm

uuzzrm commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing this in favor of #2377 - same approach (rethrow so an outage reaches the client as non-200 instead of an empty result list), and that PR is on the updated base with the full test/docs set and green CI. Keeps one PR for #2336.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Distinguish a failed search from a search with no results

1 participant