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__}") diff --git a/tests/test_authentication.py b/tests/test_authentication.py index 523b0c4f30..4f924ad20e 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -205,7 +205,7 @@ def test_multiple_entries(self, tmp_path): def test_invalid_json_raises(self, tmp_path): cfg = tmp_path / "auth.json" cfg.write_text("not json") - with pytest.raises(json.JSONDecodeError): + with pytest.raises(ValueError, match="invalid JSON"): load_auth_config(cfg) def test_not_object_raises(self, tmp_path):