From e734424006a607e45afeb20810bf068b0409811f Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 26 Mar 2026 15:54:32 +0100 Subject: [PATCH] [fix] engine - karmasearch crash when searching with long queries (#5912) Karmasearch seem to crash when searching with long queries >= 100 characters. The returned JSON is exactly this `["",[]]`, which will crash when trying to access `resp.json()["results"]` Close: https://github.com/searxng/searxng/issues/5911 Signed-off-by: Markus Heiser --- searx/engines/karmasearch.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/searx/engines/karmasearch.py b/searx/engines/karmasearch.py index fce824a14..140002c3c 100644 --- a/searx/engines/karmasearch.py +++ b/searx/engines/karmasearch.py @@ -125,7 +125,11 @@ def _parse_images(result: dict[str, t.Any]) -> LegacyResult: def response(resp: "SXNG_Response") -> EngineResults: res = EngineResults() - for result in resp.json()["results"]: + json_resp: dict[str, t.Any] = resp.json() + if not isinstance(json_resp, dict): + return res # pyright: ignore[reportUnreachable] + + for result in json_resp["results"]: # hide sponsored results if result.get("sponsored", False): continue