Skip to content

Commit 1ed25f7

Browse files
committed
fix: address integration catalog review feedback
1 parent a9d403b commit 1ed25f7

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2757,7 +2757,10 @@ def integration_catalog_list():
27572757

27582758
@integration_catalog_app.command("add")
27592759
def integration_catalog_add(
2760-
url: str = typer.Argument(..., help="Catalog URL to add (must use HTTPS)"),
2760+
url: str = typer.Argument(
2761+
...,
2762+
help="Catalog URL to add (HTTPS required, except http://localhost for local testing)",
2763+
),
27612764
name: Optional[str] = typer.Option(None, "--name", help="Catalog name"),
27622765
):
27632766
"""Add an integration catalog source to the project config."""

src/specify_cli/integrations/catalog.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,18 @@ def _load_catalog_config(
153153
raise IntegrationValidationError(
154154
f"Invalid catalog URL in {config_path} at index {idx}: {exc}"
155155
) from exc
156+
raw_priority = item.get("priority", idx + 1)
157+
if isinstance(raw_priority, bool):
158+
raise IntegrationValidationError(
159+
f"Invalid priority for catalog '{item.get('name', idx + 1)}': "
160+
f"expected integer, got {raw_priority!r}"
161+
)
156162
try:
157-
priority = int(item.get("priority", idx + 1))
163+
priority = int(raw_priority)
158164
except (TypeError, ValueError):
159165
raise IntegrationValidationError(
160166
f"Invalid priority for catalog '{item.get('name', idx + 1)}': "
161-
f"expected integer, got {item.get('priority')!r}"
167+
f"expected integer, got {raw_priority!r}"
162168
)
163169
raw_install = item.get("install_allowed", False)
164170
if isinstance(raw_install, str):

tests/integrations/test_integration_catalog.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,29 @@ def test_load_catalog_config_raises_validation_error_for_invalid_yaml(
972972
with pytest.raises(IntegrationValidationError, match="Failed to read catalog config"):
973973
cat.get_active_catalogs()
974974

975+
def test_load_catalog_config_rejects_boolean_priority(self, tmp_path, monkeypatch):
976+
self._isolate(tmp_path, monkeypatch)
977+
cfg_path = tmp_path / ".specify" / "integration-catalogs.yml"
978+
cfg_path.parent.mkdir(parents=True, exist_ok=True)
979+
cfg_path.write_text(
980+
yaml.dump(
981+
{
982+
"catalogs": [
983+
{
984+
"url": "https://a.example.com/catalog.json",
985+
"name": "a",
986+
"priority": True,
987+
}
988+
]
989+
}
990+
),
991+
encoding="utf-8",
992+
)
993+
994+
cat = IntegrationCatalog(tmp_path)
995+
with pytest.raises(IntegrationValidationError, match="Invalid priority|expected integer"):
996+
cat.get_active_catalogs()
997+
975998
def test_remove_catalog_uses_display_order_with_explicit_priorities(
976999
self, tmp_path, monkeypatch
9771000
):

0 commit comments

Comments
 (0)