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] engine - karmasearch crash when searching with long queries (#5912)

Markus Heisere734424006a6
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