From eea189286388dc270e2bcd7a3b17cc4cd76d761e Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 24 Jan 2026 07:25:49 +0100 Subject: [PATCH] [fix] presearch - AttributeError: 'NoneType' object has no attribute 'territory' (#5687) For unknown locales, the return value of:: locales.get_locale(params['searxng_locale']) is None which cuase the following issue:: ERROR searx.engines.presearch : exception : 'NoneType' object has no attribute 'territory' Traceback (most recent call last): File "search/processors/online.py", line 256, in search search_results = self._search_basic(query, params) File "search/processors/online.py", line 231, in _search_basic self.engine.request(query, params) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ File "engines/presearch.py", line 153, in request request_id, cookies = _get_request_id(query, params) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ File "engines/presearch.py", line 140, in _get_request_id if l.territory: ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'territory' Signed-off-by: Markus Heiser --- searx/engines/presearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/engines/presearch.py b/searx/engines/presearch.py index 141b292ab..55bf16adb 100644 --- a/searx/engines/presearch.py +++ b/searx/engines/presearch.py @@ -137,7 +137,7 @@ def _get_request_id(query, params): # performs an IP-based geolocation of the user, we don't want that in # SearXNG ;-) - if l.territory: + if l and l.territory: headers['Accept-Language'] = f"{l.language}-{l.territory},{l.language};" "q=0.9,*;" "q=0.5" resp = get(url, headers=headers, timeout=5)