fix: validate project path key, avoid shared mutable default

This commit is contained in:
2026-04-04 14:19:32 +02:00
parent 10a05ba55a
commit b2f38f071d
2 changed files with 15 additions and 1 deletions
+3 -1
View File
@@ -13,7 +13,9 @@ def load_config(path=CONFIG_PATH):
if not cfg or 'projects' not in cfg or not cfg['projects']:
raise ConfigError(f"'projects' list is required in {path}")
for p in cfg['projects']:
p.setdefault('benchmarks', DEFAULTS['benchmarks'])
if not isinstance(p, dict) or 'path' not in p:
raise ConfigError(f"Each project must have a 'path' key, got: {p!r}")
p.setdefault('benchmarks', list(DEFAULTS['benchmarks']))
p.setdefault('time_limit_minutes', DEFAULTS['time_limit_minutes'])
p['path'] = os.path.expanduser(p['path'])
cfg.setdefault('token_threshold', {'context_remaining_pct': 60, 'api_budget_usd': 5.0})