fix: tell a failed search apart from one with no results - #2366
Closed
uuzzrm wants to merge 1 commit into
Closed
Conversation
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
force-pushed
the
fix/search-failure-vs-empty-results
branch
from
August 14, 2026 22:58
2b1e835 to
5da39a6
Compare
Contributor
Author
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2336.
What changed
fetchSearXNGused 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:
SearXNGSearchError, and/search/text//search/imagesanswer 503 for them. A genuinely empty result set still comes back as 200 with[].startTextSearch/startImageSearchno longer derivefailedfromlength === 0. An outage leaves the statefailed; an empty result set leaves itcompleted, which renders the already-existing "No results found" alert.startTextSearchonly 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
docs/failure-injection.mdand removed the Known Limitations entry that pinned the old behavior.server/webSearchService.test.tsnow asserts the outage rejects while a zero-result search resolves to[].server/searchEndpointServerHook.test.tsasserts 503 for text and image searches when SearXNG is down, and 200 with[]for a no-result search.client/modules/textGeneration.degradation.test.tscovers: empty result set →completed, outage →failedwith no fallback, plus the image-search equivalents.client/modules/search.test.tsupdated forsearchText/searchImagespropagating failures instead of collapsing them into[].Full suite is green (
vitest run),tscpasses, and Biome/knip/jscpd report no issues.