[Bug]: A hook with a list-valued `command` passes manifest validation, then crashes `extension add` and leaves files behind
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 src/specify_cli/extensions/__init__.py 開始,閱讀第 435 行附近的 ExtensionManifest._validate,以及第 3084 行附近 install_from_directory 的 hook 註冊路徑。將 hook 驗證與 extensions/EXTENSION-API-REFERENCE.md 中記載的 string 型別進行比較;使用提供的指令碼重現問題,並檢查擴充功能驗證測試。完成條件是:非字串的 hook 命令在安裝前引發 ValidationError,且不留下任何檔案。
由索引模型根據 Issue 內容生成。
描述
Bug Description
ExtensionManifest checks only that a hook's command is truthy (src/specify_cli/extensions/__init__.py:435), so a list such as command: [speckit.test-ext.hello] is accepted. During install, HookExecutor.register_hooks uses the command as a dictionary key (__init__.py:5872), which raises TypeError: unhashable type: 'list'.
By then the extension directory has been copied and the agent skill has been written. The except handler in install_from_directory only rolls back when the generic agent is active (__init__.py:3132). With any other agent the files stay on disk, and no registry entry is written. The TypeError is not one of the exceptions specify extension add handles, so the user sees a raw traceback.
Steps to Reproduce
Save this as repro.py and run uv run python -I repro.py from the repository root.
import os, tempfile, traceback
from pathlib import Path
from typer.testing import CliRunner
from specify_cli import app
root = Path(tempfile.mkdtemp())
ext = root / "test-ext"
(ext / "commands").mkdir(parents=True)
(ext / "commands/hello.md").write_text("---\ndescription: hi\n---\n\nHello $ARGUMENTS\n")
(ext / "extension.yml").write_text("""schema_version: "1.0"
extension: {id: test-ext, name: Test, version: 1.0.0, description: d}
requires: {speckit_version: ">=0.1.0"}
provides:
commands:
- {name: speckit.test-ext.hello, file: commands/hello.md, description: x}
hooks:
after_tasks:
command: [speckit.test-ext.hello]
""")
proj = root / "project"
(proj / ".specify").mkdir(parents=True)
(proj / ".claude/skills").mkdir(parents=True)
os.chdir(proj)
r = CliRunner().invoke(app, ["extension", "add", "--dev", str(ext)])
print("exit code:", r.exit_code)
print("".join(traceback.format_exception(r.exception)[-3:]))
print("registry:", (proj / ".specify/extensions/.registry").read_text()
if (proj / ".specify/extensions/.registry").exists() else "<none>")
print("left on disk:", sorted(str(p.relative_to(proj)) for p in proj.rglob("*") if "test-ext" in str(p)))
Expected Behavior
The manifest is rejected with a ValidationError and nothing is installed. extensions/EXTENSION-API-REFERENCE.md:72 documents the field as command: string. The ExtensionManifest.__init__ docstring says it "Raises: ValidationError: If manifest is invalid" (__init__.py:243-244).
Actual Behavior
exit code: 1
registry: <none>
left on disk: ['.claude/skills/speckit-test-ext-hello', '.claude/skills/speckit-test-ext-hello/SKILL.md', '.specify/extensions/test-ext', '.specify/extensions/test-ext/.specify-dev', '.specify/extensions/test-ext/.specify-dev/agent-commands', '.specify/extensions/test-ext/.specify-dev/agent-commands/claude', '.specify/extensions/test-ext/.specify-dev/agent-commands/claude/speckit-test-ext-hello', '.specify/extensions/test-ext/.specify-dev/agent-commands/claude/speckit-test-ext-hello/SKILL.md', '.specify/extensions/test-ext/commands', '.specify/extensions/test-ext/commands/hello.md', '.specify/extensions/test-ext/extension.yml']
The command exits 1. The extension is not in the registry, but .claude/skills/speckit-test-ext-hello/SKILL.md and .specify/extensions/test-ext/ remain on disk.
Specify CLI Version
1.2.4.dev0 (main at 27d14e2)
AI Agent
Claude Code
Operating System
Linux 6.18 (Ubuntu container)
Python Version
Python 3.12.3
Error Logs
File "<checkout>/src/specify_cli/extensions/__init__.py", line 3084, in install_from_directory
hook_executor.register_hooks(manifest)
File "<checkout>/src/specify_cli/extensions/__init__.py", line 5872, in register_hooks
if command in new_entries:
^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'list'
Additional Context
Hook command values of other non-string types (a mapping, for example) take the same path. The failure-path rollback only covers the generic agent, so any other failure after command registration (for example, an unwritable .specify/extensions.yml) is likely to leave the same leftovers. That was not tested separately. Rejecting non-string hook commands in _validate would fix the reported case.
Also reproduced on macOS (Darwin 25.6, arm64) with Python 3.14.4 and uv run python -I repro.py against 27d14e2; the output matches the above.
AI Disclosure
Found and reproduced with Claude Code (model: Claude Opus 4.8), run autonomously under human supervision. The human reporter re-ran every reproduction above before filing.
- 主要語言
- Python
- 星號
- 147k
- 分支
- 13.2k
- 平均合併
- 1 天 4 小時
- 30 天內合併 PR
- 219
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/spec-kit 的其他 Issue
-
[Bug]: `bundle init <bundle>` initialises with the default integration instead of the bundle's, then aborts with a clash可能已有人在做 @chelsealong 於 13 天前認領。 未關閉triage-must-have
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
[Bug]: `specify preset set-priority` does not update agent command files that are already written可能已有人在做 @mikamikasuki 於 13 天前認領。 未關閉triage-must-have
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
-
[Bug]: Local config override file name differs between the docs (`<id>-config.local.yml`) and ConfigManager (`local-config.yml`)可能已有人在做 @gavenren 於 10 天前認領。 未關閉triage-must-have
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
[Bug]: Extension alias conflict check misses spellings that map to the same file, so one extension overwrites and then deletes another's alias可能已有人在做 @chelsealong 於 11 天前認領。 未關閉triage-must-have
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug-assess invalid triage-must-have
難度 2/5 1-3 小時 新手友好度 78/100
github/spec-kit#5079 · 1 則留言 ·
維護者通常 1 天內回覆
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
micropython/micropython#19906 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
FinanceFlash/unvibecode#597 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
TomAnthony/YourOwnWeigh#21 ·
維護者通常 1 天內回覆
-
[BUG]: Compliance rules never see Unity Catalog views as views可能已有人在做 @wagnercsantos 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
databrickslabs/ontos#1348 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 2 天內回覆