1
0

raise instead of overwriting the config file on syntax error

This commit is contained in:
f321x
2025-04-07 15:01:57 +02:00
parent 660ffa2b8f
commit 8870838834
4 changed files with 50 additions and 12 deletions

View File

@@ -900,9 +900,7 @@ def read_user_config(path: Optional[str]) -> Dict[str, Any]:
with open(config_path, "r", encoding='utf-8') as f:
data = f.read()
result = json.loads(data)
except Exception as exc:
_logger.warning(f"Cannot read config file at {config_path}: {exc}")
return {}
if not type(result) is dict:
return {}
assert isinstance(result, dict), "config file is not a dict"
except Exception as e:
raise ValueError(f"Invalid config file at {config_path}: {str(e)}")
return result