From 7665f3c602272a11d72d1c9dd96d744087330e09 Mon Sep 17 00:00:00 2001 From: Quratulain-bilal Date: Wed, 29 Jul 2026 12:19:34 +0500 Subject: [PATCH] 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. --- src/specify_cli/authentication/config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/specify_cli/authentication/config.py b/src/specify_cli/authentication/config.py index 829940d6f7..94429f3c9f 100644 --- a/src/specify_cli/authentication/config.py +++ b/src/specify_cli/authentication/config.py @@ -102,7 +102,10 @@ def load_auth_config( except OSError: pass # stat failed — skip permission check - raw = json.loads(config_path.read_text(encoding="utf-8")) + try: + raw = json.loads(config_path.read_text(encoding="utf-8")) + except json.JSONDecodeError as exc: + raise ValueError(f"{config_path} contains invalid JSON: {exc}") from exc if not isinstance(raw, dict): raise ValueError(f"auth.json must be a JSON object, got {type(raw).__name__}")