spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

fix: isolate per-extension failures so one bad extension can't drop the rest

Open PascalThuet opened this issue 5 months ago • 2 comments

What

ExtensionManager.register_enabled_extensions_for_agent iterates over enabled extensions with no per-extension error isolation. If registering one extension raised (e.g. an OSError writing a command file), the loop aborted and the exception propagated, so every subsequent enabled extension was silently skipped. The callers wrap the whole call in a single best-effort try/except, so the wholesale abort surfaced as one warning while the command still exited 0 — leaving the agent with only a prefix of its extensions registered.

This path is reached by integration switch and (since #2949 / #2886) integration install and integration upgrade.

Fix

Wrap the per-extension loop body in try/except: on failure, warn (naming the failing extension) and continue to the rest. The caller-level best-effort catch remains as a backstop.

Note the loop already guards the non-raising degraded cases — a manifest that fails to load is skipped (get_extension(...) is None → continue) and an empty registration result clears stale state — so this only adds isolation for genuine exceptions mid-loop.

Test

test_one_failing_extension_does_not_abort_the_rest installs two enabled extensions, forces the first-iterated one's registration to raise, and asserts the later extension still registers and the call does not propagate. Confirmed it fails without the fix.

Full suite: 3726 passed, 45 skipped locally.

Closes #2950

PascalThuet avatar Jun 12 '26 09:06 PascalThuet

Updated on behalf of @PascalThuet by Codex (GPT-5).

Commit: 5cdbc5fbe438105b73eb0639300a8eb7faae1a82

What changed:

  • Addressed Copilot review 4506765356 by isolating _register_extension_skills() failures from successful command registration inside register_enabled_extensions_for_agent.
  • Successful command registrations are now still persisted to registered_commands even when companion skill generation raises, preserving later cleanup/unregister behavior.
  • Added regression coverage for the command-registration-succeeds / skill-registration-fails case.
  • Merged current origin/main into the PR branch. The merge completed without manual conflicts.

Validation run locally:

  • uv run pytest tests/test_extension_skills.py -q -> 53 passed
  • uvx ruff check src/specify_cli/extensions.py tests/test_extension_skills.py -> passed
  • git diff --check -> passed

GitHub now reports the PR as mergeable. gh pr checks currently reports no checks on the branch.

PascalThuet avatar Jun 16 '26 15:06 PascalThuet

Please address Copilot feedback and rebase on upstream/main

mnriem avatar Jun 16 '26 22:06 mnriem