fix: avoid exceptions on invalid capture settings

pull/926/head
Raphaël Vinot 2024-07-16 11:51:01 +02:00
parent b9b6c3601a
commit fb50cddc8f
2 changed files with 6 additions and 4 deletions

View File

@ -433,8 +433,8 @@ class CapturesIndex(Mapping): # type: ignore[type-arg]
with capture_settings_file.open() as f:
capture_settings = json.loads(f.read())
if capture_settings.get('url') and capture_settings['url'] is not None:
cache['url'] = capture_settings['url']
if capture_settings.get('url') and capture_settings['url'] is not None:
cache['url'] = capture_settings['url']
if (capture_dir / 'error.txt').exists():
# Something went wrong

View File

@ -29,7 +29,7 @@ from werkzeug.user_agent import UserAgent
from werkzeug.utils import cached_property
from .default import get_homedir, safe_create_dir, get_config, LookylooException
from .exceptions import InvalidCaptureSetting
# from .exceptions import InvalidCaptureSetting
logger = logging.getLogger('Lookyloo - Helpers')
@ -139,7 +139,9 @@ def cast_capture_settings(capture_settings: dict[str, str]) -> CaptureSettings:
# Value is a non-empty string, keep it as-is
to_return[setting_key] = setting_value # type: ignore[literal-required]
else:
raise InvalidCaptureSetting(f'Unknown setting: {setting_key} with value: {setting_value}')
# NOTE: we may have to add more settings here, will be fixed with pydantic soon.
# raise InvalidCaptureSetting(f'Unknown setting: {setting_key} with value: {setting_value}')
print(f'Unknown setting: {setting_key} with value: {setting_value}')
return to_return