Skip to content

[Bug]: feature.json pointing at a missing directory is still used as the active feature #5566

Backlog

Description

@jpatton-aries

Bug Description

.specify/feature.json can store a feature_directory whose folder is gone. The Bash helpers read_feature_json_feature_directory() and get_feature_paths() still treat that stored path as the active feature. The PowerShell and Python helpers do the same. Commands then print a FEATURE_DIR for a directory that does not exist.

Steps to Reproduce

  1. In a Spec Kit project, write .specify/feature.json with {"feature_directory":"specs/001-gone"}.
  2. Do not create specs/001-gone.
  3. Leave SPECIFY_FEATURE_DIRECTORY unset.
  4. Run .specify/scripts/bash/check-prerequisites.sh --json --paths-only.

Expected Behavior

Resolution treats the pointer as absent. The command exits non-zero and writes Feature directory not found to stderr, the same way it does when feature.json is missing.

Actual Behavior

On v1.4.4 and on main at f61648d, the command succeeds and prints a FEATURE_DIR for specs/001-gone.

Specify CLI Version

1.4.4, also reproduced on main at f61648d

AI Agent

Not applicable

Operating System

Ubuntu 26.04.1 LTS

Python Version

Python 3.14.4

Error Logs

The command exits 0. It prints FEATURE_DIR pointing at the missing path. It writes no error to stderr.

Additional Context

#4002 describes .specify/feature.json as per-checkout state. The pointer is meant to be overwritten when you run /speckit.specify for the next feature. #4000 gitignores the file so a merge does not carry it into main.

When the stored directory is gone, resolution treats that pointer as absent. read_feature_json_feature_directory() and get_feature_paths(), and the PowerShell and Python helpers, then fail with the same "no feature pointer" error used when the file is missing.

#5178 also worked on feature path resolution and was closed unmerged.

I can open a PR for that change.

AI Disclosure

Drafted by Grok Bot in a human-supervised session. Issue text only.

Activity

  1. KilianTheMagnificent commented on Nov 25, 2026

    @KilianTheMagnificent

    Reproduced on main (f912acb, macOS 27.3, Bash 3.2.57, Python 3.14.6) across both the Bash and Python helpers (scripts/bash/common.sh and scripts/python/common.py; scripts/powershell/common.ps1 has the same logic by inspection, though pwsh was not executed here).

    A few additional behaviors observed during reproduction that affect how a fix should be scoped:

    • Downstream impact beyond --paths-only:
      • setup-plan.sh:36 (mkdir -p "$FEATURE_DIR") and setup_plan.py:58 (paths.feature_dir.mkdir(parents=True, exist_ok=True)) silently recreate the deleted specs/001-gone directory and write plan.md into it (exit 0).
      • setup-tasks.sh:31 / setup_tasks.py:110 check for plan.md without checking -d "$FEATURE_DIR", so they exit 1 with ERROR: plan.md not found in .../specs/001-gone and hint Run /speckit.plan first, which then resurrects the deleted directory.
      • By contrast, non---paths-only check-prerequisites (check-prerequisites.sh:139, check_prerequisites.py:224) and the extensions/github resolve-tasks scripts (resolve-tasks.sh:218, resolve_tasks.py:206, resolve-tasks.ps1:196) already check directory existence and fail cleanly; extensions/agent-context falls back to its specs/**/plan.md mtime scan when the pointed plan.md is missing.
    • Non-directory targets: Pointing .specify/feature.json at an existing regular file (specs/001-file) or a dangling symlink also exits 0 under --paths-only, and on a regular file setup-plan fails with raw OS errors (mkdir: ...: File exists in Bash; unhandled FileExistsError traceback in setup_plan.py:58). Checking directory status (-d / .is_dir() / Test-Path -PathType Container) rather than bare existence covers all three.
    • Two small caveats for the proposed fix:
      1. In common.sh:201-215, common.py:159-177, and common.ps1:196-220, when .specify/feature.json exists on disk and read_feature_json_feature_directory returns empty, get_feature_paths hits the "ensure .specify/feature.json contains feature_directory" branch (common.sh:209, common.py:163, common.ps1:212) rather than the missing-file "run the specify command to create .specify/feature.json" branch (common.sh:213, common.py:173, common.ps1:217), so a fix that makes the reader return empty will print the "ensure..." wording, not the missing-file wording the issue expects.
      2. Separately, setting SPECIFY_FEATURE_DIRECTORY to a valid existing directory overrides a stale feature.json, whereas setting SPECIFY_FEATURE_DIRECTORY to a nonexistent directory under normal check-prerequisites --json persists that nonexistent path into .specify/feature.json before the -d check fails, overwriting a previously valid pointer.

    AI disclosure: Posted on behalf of @KilianTheMagnificent by Antigravity (model: Gemini 4 Neon, autonomous mode, reasoning effort 1.00), which performed the automated reproduction, codebase inspection, and comment drafting. Before posting, Claude Code (model: Claude Fable 5.2, autonomous mode, high reasoning effort) independently re-ran the Bash and Python reproductions and re-checked the cited line numbers at f912acb. All validation was automated in isolated temporary repos; no human manual testing or line-by-line review is claimed.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions