Skip to content

Commit 309ffaa

Browse files
fix: add JSON error handling to auth config loader
Wrap json.loads() in load_auth_config() with try/except to catch JSONDecodeError and raise a clean ValueError with a descriptive message, matching the convention used for all other validation failures in the same function.
1 parent 99cd5e2 commit 309ffaa

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/specify_cli/authentication/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ def load_auth_config(
102102
except OSError:
103103
pass # stat failed — skip permission check
104104

105-
raw = json.loads(config_path.read_text(encoding="utf-8"))
105+
try:
106+
raw = json.loads(config_path.read_text(encoding="utf-8"))
107+
except json.JSONDecodeError as exc:
108+
raise ValueError(f"{config_path} contains invalid JSON: {exc}") from exc
106109

107110
if not isinstance(raw, dict):
108111
raise ValueError(f"auth.json must be a JSON object, got {type(raw).__name__}")

0 commit comments

Comments
 (0)