From 4dfdc822cf84f8493fb3cd16ffaf76eae0a5183e Mon Sep 17 00:00:00 2001 From: Butui Hu Date: Thu, 18 Jun 2026 01:36:22 +0800 Subject: [PATCH] [fix] engines: chinaso: handle empty upstream results gracefully (#6266) Signed-off-by: Hu Butui --- searx/engines/chinaso.py | 7 +++++++ 1 file changed, 7 insertions(+) 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)