Skip to content

integration catalog remove deletes a project source that catalog list reports as inactive while SPECKIT_INTEGRATION_CATALOG_URL is set #5524

Done

Description

@soarkit

Summary

SPECKIT_INTEGRATION_CATALOG_URL is documented as replacing the configured catalog stack: IntegrationCatalog.get_active_catalogs returns only the environment source, and specify integration catalog list prints that source under "Active catalog source from environment (non-removable here)" together with "Project/user catalog sources are not active while the env override is set." specify integration catalog remove does not apply the same rule. It reads .specify/integration-catalogs.yml directly, so remove 0 deletes the highest-priority project source even though no index was shown for it and the active stack never contained it. A user who removes the one entry they can see in the list destroys a different, hidden entry.

Environment

Spec Kit CLI 1.2.2.dev0 at commit 1c799bda6c13 (the same code is on main at a4d5712), Python 3.12, Linux aarch64. A project containing .specify/integration-catalogs.yml with two project sources, and SPECKIT_INTEGRATION_CATALOG_URL set to a custom catalog URL.

Expected behavior

While the environment override is active, catalog remove should refuse to modify the project layer, matching catalog list: either remove only an entry of the active stack (and the environment source is non-removable) or exit with an error saying that the project sources are inactive and the override must be unset first. The project YAML should be left untouched.

Actual behavior

$ SPECKIT_INTEGRATION_CATALOG_URL=https://env.example.com/catalog.json specify integration catalog list

Integration Catalog Sources:

  SPECKIT_INTEGRATION_CATALOG_URL is set; it supersedes configured catalog files.
  Project/user catalog sources are not active while the env override is set.

Active catalog source from environment (non-removable here):

  - custom — install allowed
      https://env.example.com/catalog.json
      Custom catalog via SPECKIT_INTEGRATION_CATALOG_URL

$ cat .specify/integration-catalogs.yml
catalogs:
  - name: project-team
    url: https://project.example.com/catalog.json
    priority: 7
    install_allowed: false
  - name: project-other
    url: https://other.example.com/catalog.json
    priority: 9
    install_allowed: false

$ SPECKIT_INTEGRATION_CATALOG_URL=https://env.example.com/catalog.json specify integration catalog remove 0
✓ Catalog source 'project-team' removed

$ cat .specify/integration-catalogs.yml
catalogs:
- name: project-other
  url: https://other.example.com/catalog.json
  priority: 9
  install_allowed: false

The environment source is still listed as the only active source, and the project source that was never displayed is gone.

Root cause

src/specify_cli/integrations/catalog/command_remove.py calls IntegrationCatalog.remove_catalog(index) without looking at SPECKIT_INTEGRATION_CATALOG_URL. IntegrationCatalog.remove_catalog (src/specify_cli/integrations/__init__.py:682) opens self.project_root / ".specify" / "integration-catalogs.yml" and indexes the project entries by their display order; it never calls get_active_catalogs. command_list.py does check the variable and branches on it, so the two commands disagree about which layer is active. The docstring of remove_catalog says the index is "the same display order shown by integration catalog list", which is false while the override is set.

Suggested fix

In command_remove.py, read os.environ.get("SPECKIT_INTEGRATION_CATALOG_URL", "").strip() the way command_list.py does, and when it is non-empty print an error such as "SPECKIT_INTEGRATION_CATALOG_URL is set; project and user catalog sources are not active and cannot be removed" and exit 1. Alternatively, give remove_catalog the resolved active stack and index into that. Add a regression test next to the other contract tests: with a two-entry project config and the environment variable set, remove_catalog(0) must raise IntegrationValidationError and the YAML must be unchanged, while the same call with the variable unset still removes the first entry.

Activity

  1. added
    triage-must-have
    on Nov 23, 2026
  2. media-ctrl commented on Nov 23, 2026

    @media-ctrl

    remove_catalog's own docstring states the invariant this breaks (src/specify_cli/integrations/__init__.py:695): the index a user sees in catalog list is the index they pass to remove. The env branch of get_active_catalogs (:267) makes that false. catalog list renders the env entry at index 0, while remove_catalog re-sorts the project YAML and deletes its highest-priority entry, which the user was never shown.

    catalog add has the same shape and has not been reported. add_catalog (:571) writes .specify/integration-catalogs.yml with no env check, so under the override it appends a source the active stack will never read, then prints success. Both writers want one pre-check: if the override is set, refuse and name it.

    On tests, every catalog test clears the variable first (test_command_add.py:17, test_command_list.py:29, test_command_remove.py:52, test_catalog.py:148 call monkeypatch.delenv), so the combination has no coverage at all. The regression that would have caught this is remove 0 with the override set, asserting the YAML is unchanged byte for byte and the exit code non-zero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-must-have

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions