Skip to content

fix: silence git fetch stdout to prevent branch number parse error#1696

Open
fsilvaortiz wants to merge 2 commits intogithub:mainfrom
fsilvaortiz:fix/silence-git-fetch-stdout-in-create-feature
Open

fix: silence git fetch stdout to prevent branch number parse error#1696
fsilvaortiz wants to merge 2 commits intogithub:mainfrom
fsilvaortiz:fix/silence-git-fetch-stdout-in-create-feature

Conversation

@fsilvaortiz
Copy link

@fsilvaortiz fsilvaortiz commented Feb 25, 2026

Summary

Fixes create-new-feature.sh --json failing with:

line 250: 10#Fetching: value too great for base (error token is "10#Fetching")

Root cause: git fetch --all --prune 2>/dev/null only silences stderr. When git fetch writes status text (e.g., Fetching origin...) to stdout, it gets captured by command substitution in check_existing_branches(), contaminating BRANCH_NUMBER with non-numeric text. The subsequent $((10#$BRANCH_NUMBER)) then fails.

Fix: Redirect both stdout and stderr to /dev/null:

- git fetch --all --prune 2>/dev/null || true
+ git fetch --all --prune >/dev/null 2>&1 || true

Closes #1592

Test plan

  • Verified the fix silences both stdout and stderr from git fetch
  • All tests pass (100/100 — 95 existing + 5 new)
  • Added 5 new tests in tests/test_create_new_feature.py:
    • test_json_output_is_valid — JSON output has correct keys
    • test_feature_num_is_numeric — FEATURE_NUM is always zero-padded numeric
    • test_script_does_not_leak_git_fetch_stdout — no fetch noise in stdout
    • test_script_does_not_leak_git_fetch_to_json — repeated runs produce clean JSON
    • test_git_fetch_redirect_pattern_in_script — regression guard for the redirect pattern (no git required)
  • Tests that require git are marked with pytest.mark.skipif for environments without git

AI Assistance Disclosure

This PR was drafted with assistance from Claude Code (Anthropic). The root cause analysis, fix, and tests were validated manually by the author.

🤖 Generated with Claude Code

`git fetch --all` can write status text (e.g., "Fetching origin...") to
stdout, which gets captured by command substitution in
check_existing_branches(). This contaminates BRANCH_NUMBER with
non-numeric text, causing `$((10#$BRANCH_NUMBER))` to fail with
"value too great for base".

Redirect both stdout and stderr to /dev/null instead of stderr only.

Closes github#1592

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fsilvaortiz fsilvaortiz requested a review from mnriem as a code owner February 25, 2026 23:03
…cing

Adds 5 tests covering:
- Valid JSON output from --json flag
- FEATURE_NUM is always a zero-padded numeric string
- No git fetch stdout leaks into JSON output
- Repeated runs produce clean JSON without fetch artifacts
- Regression guard: git fetch redirects both stdout and stderr

Tests that require git are marked with skipif so they degrade
gracefully in environments without git installed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fsilvaortiz fsilvaortiz force-pushed the fix/silence-git-fetch-stdout-in-create-feature branch from db3da6f to a45e9f0 Compare February 25, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create-new-feature.sh --json can fail with '10#Fetching: value too great for base'

1 participant