summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2022-12-05 13:43:38 +0100
committerGitHub <noreply@github.com>2022-12-05 13:43:38 +0100
commit67eea86b35a1f5b9f5f17e0438332f15e852a22e (patch)
tree87cefff16d201a821ac8e554e08ae930246969e0 /searx
parentffb72dfdf7c364fa85e6814b9952703d65b1c274 (diff)
parent269326063ac9113dacb222c3b1dd0516483e05b8 (diff)
downloadsearxng-67eea86b35a1f5b9f5f17e0438332f15e852a22e.tar.gz
searxng-67eea86b35a1f5b9f5f17e0438332f15e852a22e.zip
Merge pull request #2006 from dalf/fix_1951
Fix: don't crash when engine or name is missing in settings.yml
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/__init__.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
index c61f50d4b..52bb5f20d 100644
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -106,8 +106,12 @@ def load_engine(engine_data: dict) -> Optional[Engine]:
- required attribute is not set :py:func:`is_missing_required_attributes`
"""
+ # pylint: disable=too-many-return-statements
- engine_name = engine_data['name']
+ engine_name = engine_data.get('name')
+ if engine_name is None:
+ logger.error('An engine does not have a "name" field')
+ return None
if '_' in engine_name:
logger.error('Engine name contains underscore: "{}"'.format(engine_name))
return None
@@ -118,7 +122,10 @@ def load_engine(engine_data: dict) -> Optional[Engine]:
engine_data['name'] = engine_name
# load_module
- engine_module = engine_data['engine']
+ engine_module = engine_data.get('engine')
+ if engine_module is None:
+ logger.error('The "engine" field is missing for the engine named "{}"'.format(engine_name))
+ return None
try:
engine = load_module(engine_module + '.py', ENGINE_DIR)
except (SyntaxError, KeyboardInterrupt, SystemExit, SystemError, ImportError, RuntimeError):