Repository navigation
Conversation
…no feature `check-prerequisites --json --paths-only` exited 0 and printed FEATURE_DIR, FEATURE_SPEC, IMPL_PLAN and TASKS under a directory that no longer exists whenever .specify/feature.json still pointed at it, while the same command with no feature.json exited 1. get_feature_paths in the bash, python and PowerShell helpers accepted the stored feature_directory without checking that its target is a directory. The feature.json branch now requires the normalized path to be a directory and otherwise emits the existing missing-pointer error and exits 1, so a stale pointer, a pointer to a regular file and a pointer to a dangling symlink are all treated as no feature. The SPECIFY_FEATURE_DIRECTORY branch is unchanged: naming a directory that does not exist yet is a legitimate use of the explicit override. Assisted-by: ZCode (model: GLM-5.4, autonomous)
…nter names With the stale-pointer fix in get_feature_paths these tests fail for the right reason: they wrote a .specify/feature.json pointer to a directory that was never created and relied on setup-plan recreating it. Their subject is unchanged (composing SPECIFY_INIT_DIR with an existing feature.json; plan.md created and not overwritten; JSON output parseable) and the fixture only used the pointer as setup, so the tests now create that directory themselves. Adjusted in tests/test_setup_plan_no_overwrite.py: the plan_repo fixture, test_setup_plan_preserves_existing_plan, test_setup_plan_skip_message_on_stderr_in_json_mode, test_ps_setup_plan_preserves_existing_plan and test_ps_setup_plan_does_not_match_another_features_plan. Adjusted in tests/test_init_dir.py: test_composes_with_target_feature_json. Assisted-by: ZCode (model: GLM-5.4, autonomous)
There was a problem hiding this comment.
🟡 Changes recommended
The tests can reject valid Git Bash paths on Windows, and the host selector leaves required Windows PowerShell 5.1 validation uncovered.
2 open issues
What changed in this PR
Fixes #5566 by rejecting stored feature pointers whose directories no longer exist, consistently across Spec Kit’s three script implementations.
Changes:
- Validate persisted feature directories while preserving explicit environment overrides.
- Add stale-pointer regression tests and positive controls.
- Update existing fixtures to create directories referenced by valid pointers.
Review assistance: GitHub Copilot, model unknown, autonomous, for the requester; analysis and suggested fixes. Tests were not run.
| File | Description |
|---|---|
| tests/test_setup_plan_no_overwrite.py | Create valid feature directories in fixtures. |
| tests/test_init_dir.py | Create the directory referenced by the test pointer. |
| tests/test_feature_json_stale_pointer.py | Add cross-port pointer validation tests. |
| scripts/python/common.py | Reject stored paths that are not directories. |
| scripts/powershell/common.ps1 | Validate stored directories using literal paths. |
| scripts/bash/common.sh | Reject stored paths that are not directories. |
Review effort: Balanced (adaptive)
The PowerShell port of the matrix picked pwsh whenever both hosts were installed, so the stale-pointer cases never ran under Windows PowerShell 5.1, the host CONTRIBUTING.md asks for evidence from when PowerShell behaviour changes. The matrix now has a separate windows-powershell port next to pwsh, and each host runs the full set of cases. Path assertions go through a small helper that turns the /c/... drive spelling Git for Windows Bash can emit into C:/... before Path() compares it with the fixture's C:\... spelling. Off Windows the helper is a no-op. Assisted-by: ZCode (model: GLM-5.4, autonomous)
There was a problem hiding this comment.
🔵 Needs a closer look
Maintainer review is needed for the shared resolver’s cross-session recovery compatibility change, with dangling-symlink handling also unverified on Windows PowerShell 5.1.
No open issues 🎉
2 resolved since last review
Review effort: Balanced (adaptive)

Description
check-prerequisites --json --paths-onlyexits 0 and printsFEATURE_DIR,FEATURE_SPEC,IMPL_PLANandTASKSunder a directory that no longer exists when.specify/feature.jsonpoints at it; with nofeature.jsonit exits 1 withERROR: Feature directory not found. ....Cause:
get_feature_paths(bash, Python, PowerShell) accepted the storedfeature_directorywithout checking that its target is a directory.Fix: in the
feature.jsonbranch only, the normalized path must be a directory (-d,is_dir(),Test-Path -PathType Container), else the script prints the existing missing-pointer error and exits 1. TheSPECIFY_FEATURE_DIRECTORYbranch is untouched: naming a not-yet-existing directory is a legitimate use of it.Behaviour change to be aware of
setup-planno longer recreates a directory the pointer names. Ifcheck-prerequisites.sh --jsonruns withSPECIFY_FEATURE_DIRECTORYnaming a not-yet-existing directory, it exits 1 but still persists that path.setup-plan.sh --jsonin a later session without the variable used to exit 0 and createplan.mdwith nospec.md; it now exits 1 with the missing-pointer error. With the variable exported, as documented, nothing changes.Alternatives considered
Narrowing the check to
check-prerequisitesonly, sosetup-plankeeps recreating the directory from a stale pointer.Fixes #5566. Reported by
jpatton-aries, reproduced byKilianTheMagnificent.Testing
Set up this checkout's
.venvand editable install using the local development guide. Run commands from the checkout root..venv/bin/specify --help(Windows PowerShell:.\.venv\Scripts\specify.exe --help).venv/bin/python -m pytest tests -q(Windows PowerShell:.\.venv\Scripts\python.exe -m pytest tests -q); use affected test paths for focused checks andLC_ALL=en_US.UTF-8on macOSExisting tests adjusted.
tests/test_setup_plan_no_overwrite.pyandtests/test_init_dir.pypointed at a directory they never created and relied onsetup-planrecreating it. Their subject is unchanged (SPECIFY_INIT_DIRwith an existingfeature.json;plan.mdcreated, not overwritten; JSON parseable); they now create that directory.New
tests/test_feature_json_stale_pointer.pyruns four ports: bash,pwsh,windows-powershell(Windows PowerShell 5.1) and Python. Locally 12 passed, 12 skipped (no PowerShell host on this machine); without the fix the six bash/Python stale-pointer cases fail with exit 0 and a printedFEATURE_DIR. Full suite at the second commit: 17682 passed, 674 skipped, 0 failed; the third commit touches only that test file.Caveats: neither PowerShell port was executed locally; CI is their first run, including the
windows-powershellport that carries the 5.1 evidence. The dangling-symlink case on PowerShell is unverified. Checklist items one and three are unchecked: no manual testing.AI Disclosure
AI disclosure: Authored by the agent ZCode, model GLM-5.4, autonomous mode, on behalf of the account holder (
pengzh1). The agent wrote the code and the tests; no human reviewed the change or tested it manually before this PR was opened.