[BUG] Claude Code CLI hangs with unhandled promise rejection when executing GitHub CLI commands with complex parameter expansion
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version: 0.2.69 (Claude Code)
- Operating System: macOS version 15.4 (Build 24E248)
- Terminal: Warp v0.2025.04.09.08.11.stable_02
Bug Description
Claude Code CLI hangs, and only responds with api 400 errors with an unhandled promise rejection when running a GitHub CLI (gh)
command with specific shell parameter expansion. The error occurs when attempting to execute
gh api repos/${GH_ORG_NAME:-$(whoami)}/${GH_REPO_NAME:-$(basename $(pwd))}/milestones
as part of a GitHub repository setup workflow.
Steps to Reproduce
- Start a Claude Code CLI session
- Load a project with GitHub integration
- Run a command with shell parameter expansion combined with GitHub API access: gh api repos/${GH_ORG_NAME:-$(whoami)}/${GH_REPO_NAME:-$(basename $(pwd))}/milestones
- Observe that Claude crashes with an unhandled promise rejection
Expected Behavior
Claude should either successfully execute the command or gracefully handle any errors that occur during execution, presenting an error message to the user without crashing.
Actual Behavior
Screenshot:
Claude hangs with the following error message: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
-
Future prompts error out with 400 api errors. Restarting claude fixes it.
-
the process appears to keep running, but is not active
⏺ Bash(gh api repos/${GH_ORG_NAME:-$(whoami)}/${GH_REPO_NAME:-$(basename $(pwd))}/milestones)… ⎿ Running…
⚗ Progressing… (17s · esc to interrupt)
Additional Context
- The issue appears to be related to complex shell parameter expansion when calling GitHub API endpoints
- A workaround was identified by using more direct commands without variable substitution: gh api repos/$(gh repo view --json owner -q .owner.login)/$(gh repo view --json name -q .name)/milestones
- The problem might be related to how Claude's Bash tool handles nested command substitution and variable expansion in complex commands
- The error is reproducible and consistent when running the specific command pattern
Exactly the same error since I add GIT to chat with Claude. Since then, basic Mac Terminal commands failed with that error.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.