[BUG] Claude Code CLI hangs with unhandled promise rejection when executing GitHub CLI commands with complex parameter expansion

Resolved 💬 4 comments Opened Apr 14, 2025 by ruzz Closed Jan 3, 2026

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • 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

  1. Start a Claude Code CLI session
  2. Load a project with GitHub integration
  3. 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

  1. 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: <img width="794" alt="Image" src="https://github.com/user-attachments/assets/e3a41580-0034-4edd-9c03-e9a388ff041a" />

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

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗