From 1708e5c32b3b188ec3eb3411adfccefbc9ee0db4 Mon Sep 17 00:00:00 2001 From: Quratulain-bilal Date: Sun, 31 May 2026 01:40:49 +0500 Subject: [PATCH] fix(catalogs): include URL in missing-keys error to match sibling branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses Copilot review feedback on this PR (round 3). ``_validate_catalog_payload`` advertises in its docstring that the catalog URL is included in error messages "so the user can tell which catalog in a multi-catalog stack is malformed" — but the missing-keys branch raised ``PresetError("Invalid preset catalog format")`` without the URL, breaking that contract and making multi-catalog debugging harder. The root-bad-type and nested-bad-type branches in the same helper already include the URL; this commit brings the middle branch in line. For consistency, the same fix is applied to the legacy single-catalog fetch paths in ``ExtensionCatalog.fetch_catalog`` and ``PresetCatalog.fetch_catalog`` (where the URL was likewise dropped from the missing-keys error). The existing regex matchers in the regression tests target the ``"Invalid (preset )?catalog format"`` prefix, which is preserved verbatim before the ``from `` suffix — no test changes needed. --- src/specify_cli/extensions.py | 2 +- src/specify_cli/presets.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/specify_cli/extensions.py b/src/specify_cli/extensions.py index de67dfcdd..9ee09297d 100644 --- a/src/specify_cli/extensions.py +++ b/src/specify_cli/extensions.py @@ -2012,7 +2012,7 @@ class ExtensionCatalog(CatalogStackBase): # Validate catalog structure if "schema_version" not in catalog_data or "extensions" not in catalog_data: - raise ExtensionError("Invalid catalog format") + raise ExtensionError(f"Invalid catalog format from {catalog_url}") # Save to cache self.cache_dir.mkdir(parents=True, exist_ok=True) diff --git a/src/specify_cli/presets.py b/src/specify_cli/presets.py index 89fd03318..08aaa045f 100644 --- a/src/specify_cli/presets.py +++ b/src/specify_cli/presets.py @@ -1895,7 +1895,7 @@ class PresetCatalog: "schema_version" not in catalog_data or "presets" not in catalog_data ): - raise PresetError("Invalid preset catalog format") + raise PresetError(f"Invalid preset catalog format from {url}") if not isinstance(catalog_data.get("presets"), dict): raise PresetError( f"Invalid preset catalog format from {url}: " @@ -2199,7 +2199,7 @@ class PresetCatalog: "schema_version" not in catalog_data or "presets" not in catalog_data ): - raise PresetError("Invalid preset catalog format") + raise PresetError(f"Invalid preset catalog format from {catalog_url}") self.cache_dir.mkdir(parents=True, exist_ok=True) self.cache_file.write_text(json.dumps(catalog_data, indent=2))