mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix(searxng): preserve upstream HTTP errors instead of returning empty results
The search adapter built a SearchResponse from raw_response.json() without
checking the status code. A 429 or 503 from the SearXNG instance has no
"results" key, so response_json.get("results", []) produced an empty list and
the caller received a successful response with zero results.
That makes a retryable provider failure indistinguishable from a query that
genuinely matched nothing, so fallback between configured search tools never
fires. The HTTP handlers for this provider do not call raise_for_status either,
so no other layer inspects the status.
Raise through the provider's own error class so the existing retry and fallback
machinery classifies it. The upstream body is deliberately not included in the
message, because it can echo the original query.
This commit is contained in:
parent
bd7e9c1997
commit
53ebcb0bf4
1 changed files with 13 additions and 0 deletions
|
|
@ -204,6 +204,19 @@ class SearXNGSearchConfig(BaseSearchConfig):
|
|||
Returns:
|
||||
SearchResponse with standardized format
|
||||
"""
|
||||
if not 200 <= raw_response.status_code < 300:
|
||||
# The HTTP handlers for this provider do not call raise_for_status,
|
||||
# so an upstream 429/503 would otherwise be parsed as a successful
|
||||
# response with zero results. The upstream body is deliberately not
|
||||
# echoed, because it can contain the original query.
|
||||
raise self.get_error_class(
|
||||
error_message=(
|
||||
f"SearXNG search provider returned HTTP {raw_response.status_code}"
|
||||
),
|
||||
status_code=raw_response.status_code,
|
||||
headers=dict(raw_response.headers),
|
||||
)
|
||||
|
||||
response_json: Final = raw_response.json()
|
||||
|
||||
# Transform results to SearchResult objects
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue