-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[Bug]: create-new-feature.sh swallows git checkout stderr and makes branch failures impossible to diagnose #2105
Description
Bug Description
Summary
create-new-feature.sh hides the real Git error when branch creation or branch switching fails.
That makes troubleshooting much harder than it needs to be, because the script only reports a generic message like:
Error: Failed to create git branch '001-setup-prompts'. Please check your git configuration and try again.Error: Failed to switch to existing branch '001-setup-prompts'. Please resolve any local changes or conflicts and try again.
In our case, the real underlying Git error was about lock-file creation permissions, but the script suppressed it.
Where
This appears to come from create-new-feature.sh, where git checkout -b ... and git checkout ... redirect stderr to /dev/null.
Relevant lines in our generated script:
- line 330:
git checkout -b "$BRANCH_NAME" 2>/dev/null - line 335:
git checkout "$BRANCH_NAME" 2>/dev/null
Steps to Reproduce
In our environment, running the script failed:
bash .specify/scripts/bash/create-new-feature.sh \
--json \
--short-name "setup-prompts" \
"Add interactive setup prompts for locale and completed retention days"The script only returned a generic error.
Running the equivalent Git commands manually exposed the real cause:
git checkout -b 003-sandbox-probefatal: cannot lock ref 'refs/heads/003-sandbox-probe': Unable to create '.git/refs/heads/003-sandbox-probe.lock': Operation not permitted
And:
git checkout 001-setup-promptsfatal: Unable to create '.git/index.lock': Operation not permitted
Expected Behavior
If branch creation or branch switching fails, the script should surface the real Git error instead of hiding it behind a generic message.
At minimum, it should do one of the following:
- print Git's stderr directly
- capture Git's stderr and include it in the final error message
- preserve enough detail for the user to understand whether the failure is caused by:
- an existing branch
- local changes
- a lock file / permission issue
- a worktree-related constraint
- another Git error
Example of acceptable behavior:
Error: Failed to create git branch '001-setup-prompts'
Git error: fatal: cannot lock ref 'refs/heads/001-setup-prompts': Unable to create '.git/refs/heads/001-setup-prompts.lock': Operation not permitted
A friendly wrapper message is fine, but the original Git stderr should still be visible.
Actual Behavior
When branch creation or branch switching fails, the script suppresses Git's stderr and only prints a generic message.
Example:
Error: Failed to create git branch '001-setup-prompts'. Please check your git configuration and try again.
As a result, the user cannot tell whether the real cause is:
- an existing branch
- local changes
- a Git lock/permission issue
- a worktree constraint
- or another Git failure
Specify CLI Version
0.5.1.dev0
AI Agent
Claude Code
Operating System
macOS 26.3.1 (Build 25D771280a)
Python Version
Python 3.11.6
Error Logs
fatal: cannot lock ref 'refs/heads/003-sandbox-probe': Unable to create '/Users/pascalthuet/Documents/SourcCode/ThingsSync-new/.git/refs/heads/003-sandbox-probe.lock': Operation not permitted
fatal: Unable to create '/Users/pascalthuet/Documents/SourcCode/ThingsSync-new/.git/index.lock': Operation not permittedAdditional Context
This may be related in spirit to branch-creation issues already discussed in the project, but the specific problem here is diagnosability: the script discards the real Git failure reason, which makes environment-specific failures look like generic Spec Kit failures.