From 4ab8b3a2e5c9a4bbac9d5abf9167f90915181c9a Mon Sep 17 00:00:00 2001 From: marcelsafin <179933638+marcelsafin@users.noreply.github.com> Date: Wed, 12 Aug 2026 23:53:46 +0200 Subject: [PATCH] fix(bundler): reject unsupported catalog payload versions Assisted-by: GitHub Copilot (model: gpt-5.6-sol, autonomous) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/specify_cli/bundler/models/catalog.py | 11 +++++++++++ tests/contract/test_catalog_schema.py | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/specify_cli/bundler/models/catalog.py b/src/specify_cli/bundler/models/catalog.py index 53e83a52e7..2eede0a557 100644 --- a/src/specify_cli/bundler/models/catalog.py +++ b/src/specify_cli/bundler/models/catalog.py @@ -20,6 +20,7 @@ # reject an unsupported major version so a file written by a newer/incompatible # Spec Kit fails fast instead of being parsed under the wrong assumptions. CONFIG_SCHEMA_VERSION = "1.0" +CATALOG_SCHEMA_VERSION = "1.0" class InstallPolicy(str, Enum): @@ -215,6 +216,16 @@ def load_catalog_payload(data: Any) -> dict[str, CatalogEntry]: """Parse a catalog JSON payload into ``{bundle_id: CatalogEntry}``.""" if not isinstance(data, dict): raise BundlerError("Catalog payload must be a JSON object.") + schema_version = data.get("schema_version") + if schema_version is not None and ( + str(schema_version).strip().split(".")[0] + != CATALOG_SCHEMA_VERSION.split(".")[0] + ): + raise BundlerError( + f"Unsupported catalog schema version " + f"'{str(schema_version).strip()}'; this Spec Kit understands " + f"version {CATALOG_SCHEMA_VERSION}." + ) bundles_raw = data.get("bundles") if not isinstance(bundles_raw, dict): raise BundlerError("Catalog payload is missing a 'bundles' object.") diff --git a/tests/contract/test_catalog_schema.py b/tests/contract/test_catalog_schema.py index 15a844118b..e341f783cf 100644 --- a/tests/contract/test_catalog_schema.py +++ b/tests/contract/test_catalog_schema.py @@ -300,6 +300,14 @@ def test_catalog_entry_rejects_non_mapping_provides(): CatalogEntry.from_dict(data) +def test_load_payload_rejects_unsupported_schema_version(): + payload = catalog_payload({"demo": catalog_entry_dict("demo")}) + payload["schema_version"] = "2.0" + + with pytest.raises(BundlerError, match="Unsupported catalog schema version"): + load_catalog_payload(payload) + + @pytest.mark.parametrize("field", ["requires", "provides"]) @pytest.mark.parametrize("bad", [[], "", 0, False]) def test_catalog_entry_rejects_falsy_non_mapping(field, bad):