Skip to content

fix(extensions): delete the catalog config when the last entry is removed - #4909

Open
Chaoqi31 wants to merge 2 commits into
github:mainfrom
Chaoqi31:fix/extension-catalog-remove-last
Open

Chaoqi31 wants to merge 2 commits into
github:mainfrom
Chaoqi31:fix/extension-catalog-remove-last

Conversation

@Chaoqi31

Copy link
Copy Markdown

Description

specify extension catalog remove <name> on the last project catalog prints "No catalogs remain in config. Built-in defaults will be used." but writes .specify/extension-catalogs.yml as catalogs: []. The extension catalog loader rejects an existing config with no entries (on purpose, see test_empty_project_config_raises_error), so every later catalog-backed command fails until the user deletes the file by hand:

$ specify extension catalog add https://only.example.com/catalog.json --name only
$ specify extension catalog remove only
✓ Removed catalog 'only'
No catalogs remain in config. Built-in defaults will be used.
$ cat .specify/extension-catalogs.yml
catalogs: []
$ specify extension catalog list
Error: Catalog config .../.specify/extension-catalogs.yml exists but contains no 'catalogs' entries. Remove the file to use built-in defaults, or add valid catalog entries.

extension search, extension info, extension add <id> for any id that is not bundled, and extension update once an extension is installed fail the same way.

This PR deletes the file when the last entry is removed, which is what specify integration catalog remove already does (IntegrationCatalog.remove_catalog, pinned by test_catalog_remove_final_entry_restores_defaults). The built-in default and community catalogs are active again, as the message says (or the user-level ~/.specify/extension-catalogs.yml, when one exists; it is the next layer in the resolution order). The other catalog remove commands are not affected: presets, workflows and workflow steps treat an empty list as no config, and bundles always add the built-in catalogs.

Testing

  • New test_extension_catalog_remove_final_entry_restores_defaults: add one catalog, remove it, then extension catalog list exits 0 and lists default and community, and the config file is gone. On main it fails with the error above (assert 1 == 0).
  • New negative case test_extension_catalog_remove_keeps_config_with_remaining_entries: removing one of two entries keeps the file with the other entry unchanged.
  • tests/specify_cli: 4416 passed, 2 skipped. tests/test_extensions.py: 464 passed.
  • Reran the CLI steps above against this branch: .specify/ is left empty and extension catalog list exits 0 with the built-in stack.

Equivalent local checks: tests ran with .venv/bin/python -m pytest and the CLI with the venv's specify, on macOS.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure: This contribution was produced by Claude Code running autonomously on behalf of @Chaoqi31. An audit agent (Claude Fable 5.1, max reasoning effort) found the bug and wrote a failing reproduction. A fix agent (Claude Opus 5, xhigh effort) wrote the fix and tests. A separate review agent checked the branch, and the orchestrating agent (Claude Opus 5) wrote the commits and this description. AI generated the code, tests and text. No human reviewed the diff line by line before submission.

Assisted-by: Claude Code (model: Claude Opus 5, autonomous)
…oved

`specify extension catalog remove` wrote `catalogs: []` after dropping the
last entry and printed that built-in defaults would be used. The catalog
loader rejects an existing config with no entries, so every later
catalog-backed command (`catalog list`, `search`, `add`, `update`, `info`)
failed until the file was deleted by hand. Delete the file instead, as
`specify integration catalog remove` already does.

Assisted-by: Claude Code (model: Claude Opus 5, autonomous)
@Chaoqi31
Chaoqi31 requested a review from mnriem as a code owner October 10, 2026 04:51

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant