Reject invalid preset CLI stores (#1395)

This commit is contained in:
red person
2026-06-02 21:59:05 +03:00
committed by GitHub
parent a5282e9748
commit abbc073429
2 changed files with 32 additions and 1 deletions

View File

@@ -28,9 +28,12 @@ def _load() -> dict:
if not _PATH.exists():
return {}
try:
return json.loads(_PATH.read_text())
data = json.loads(_PATH.read_text())
except json.JSONDecodeError as e:
fail(f"presets.json corrupt: {e}")
if not isinstance(data, dict):
fail("presets.json corrupt: expected an object")
return data
def _save(data: dict) -> None: