fix(settings): catch PermissionError in load_settings + error-path tests (#1570)

PermissionError was not in the except tuple so an unreadable settings.json
would crash the app instead of falling back to defaults. Added alongside the
existing FileNotFoundError/JSONDecodeError/ValueError catches.

Also adds test_settings_error_paths.py covering all four failure modes:
missing file, corrupted JSON, wrong type, and permission denied.
This commit is contained in:
Lucas Daniel
2026-06-03 02:23:27 -03:00
committed by GitHub
parent cbf8103cba
commit 398892cced
2 changed files with 95 additions and 1 deletions
+1 -1
View File
@@ -187,7 +187,7 @@ def load_settings() -> dict:
if not isinstance(saved, dict):
raise ValueError("settings must be an object")
merged = {**DEFAULT_SETTINGS, **saved}
except (FileNotFoundError, json.JSONDecodeError, ValueError):
except (FileNotFoundError, PermissionError, json.JSONDecodeError, ValueError):
merged = dict(DEFAULT_SETTINGS)
_settings_cache = (now, merged)
return merged