From 51478792ca043a60c3bdf3a2a3714e10a2d395df Mon Sep 17 00:00:00 2001 From: Quratulain-bilal Date: Fri, 31 Jul 2026 16:49:46 +0500 Subject: [PATCH] fix: skip corrupted state.json in list_runs() instead of aborting If any single state.json file is corrupted, truncated, or unreadable, the unhandled exception aborts the entire iteration and all subsequent valid runs are never listed. Catch OSError, JSONDecodeError, and UnicodeDecodeError to skip bad entries gracefully. --- src/specify_cli/workflows/engine.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/specify_cli/workflows/engine.py b/src/specify_cli/workflows/engine.py index fe049fd840..82ced9a3bd 100644 --- a/src/specify_cli/workflows/engine.py +++ b/src/specify_cli/workflows/engine.py @@ -1676,9 +1676,12 @@ def list_runs(self) -> list[dict[str, Any]]: continue state_path = run_dir / "state.json" if state_path.exists(): - with open(state_path, encoding="utf-8") as f: - state_data = json.load(f) - runs.append(state_data) + try: + with open(state_path, encoding="utf-8") as f: + state_data = json.load(f) + runs.append(state_data) + except (OSError, json.JSONDecodeError, UnicodeDecodeError): + continue return runs