@@ -43,11 +43,15 @@ def _api_get(url: str, headers: dict[str, str], params: dict[str, str] | None =
4343
4444def _run_group (run : dict ) -> str :
4545 """Return the benchmark group for a run."""
46+ if "meta" not in run :
47+ raise ValueError (f"Run dict missing 'meta' key. Keys present: { list (run .keys ())} " )
4648 return run ["meta" ]["group" ]
4749
4850
4951def _run_workflow (run : dict ) -> dict :
5052 """Return the workflow payload for a run."""
53+ if "workflow" not in run :
54+ raise ValueError (f"Run dict missing 'workflow' key. Keys present: { list (run .keys ())} " )
5155 return run ["workflow" ]
5256
5357
@@ -120,8 +124,11 @@ def load_run_data(data_dir: Path) -> list[dict]:
120124 """Load all run JSON files from a directory."""
121125 runs = []
122126 for run_file in sorted (data_dir .glob ("*.json" )):
123- with run_file .open () as f :
124- runs .append (json .load (f ))
127+ try :
128+ with run_file .open () as f :
129+ runs .append (json .load (f ))
130+ except json .JSONDecodeError as e :
131+ raise ValueError (f"Malformed JSON in { run_file .name } : { e } " ) from e
125132 return runs
126133
127134
@@ -672,8 +679,11 @@ def load_brand(brand_path: Path | None = None) -> dict:
672679 ],
673680 }
674681 if brand_path and brand_path .exists ():
675- with brand_path .open () as f :
676- raw = yaml .safe_load (f ) or {}
682+ try :
683+ with brand_path .open () as f :
684+ raw = yaml .safe_load (f ) or {}
685+ except yaml .YAMLError :
686+ raw = {}
677687 colors = raw .get ("colors" , {})
678688 gp = colors .get ("green_palette" , {})
679689 ns = colors .get ("neutrals" , {})
0 commit comments