[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 <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser
2026-03-26 15:54:32 +01:00
committed by GitHub
parent fe1d6d9c48
commit e734424006
+5 -1
View File
@@ -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