Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[fix] engines: chinaso: handle empty upstream results gracefully (#6266)

Butui Hu4dfdc822cf84
diff --git a/searx/engines/chinaso.py b/searx/engines/chinaso.py
index a94f4059e..da03acb54 100644
--- a/searx/engines/chinaso.py
+++ b/searx/engines/chinaso.py
@@ -156,6 +156,13 @@ def response(resp):
except Exception as e:
raise SearxEngineAPIException(f"Invalid response: {e}") from e
+ # Upstream returns {'status': 0, 'msg': 'empty result', 'data': {}} when there
+ # are no results; this is a valid empty result rather than an API error.
+ if not isinstance(data, dict) or "data" not in data:
+ raise SearxEngineAPIException("Invalid response")
+ if not data["data"]:
+ return []
+
parsers = {'news': parse_news, 'images': parse_images, 'videos': parse_videos}
return parsers[chinaso_category](data)