[BUG] CLI crashes when rejecting permission-required tool use within Task tool

Resolved 💬 3 comments Opened Jul 19, 2025 by takahirom Closed Aug 3, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.56 (Claude Code)
  • Operating System: macOS 14.3 (Darwin 24.3.0)
  • Terminal: <!-- e.g. iTerm2, Terminal App -->

Bug Description

Claude Code crashes with TypeError: Cannot read properties of undefined (reading 'message') when user rejects a permission-required tool use (such as Bash commands) within the Task tool via the interactive prompt.

Steps to Reproduce

  1. Start Claude Code with claude
  2. Enter "Please run rm no-exists-file in task tool"
  3. Task tool attempts to use Bash tool (which requires permission)
  4. When the tool use permission prompt appears, press 3 or choose "No, and tell Claude what to do differently (esc)"
  5. CLI crashes with TypeError

Expected Behavior

The CLI should gracefully handle the tool rejection and either:

  • Show a message that the tool use was rejected
  • Ask for alternative instructions
  • Continue the conversation without crashing

Actual Behavior

The CLI crashes with the following error:

TypeError: Cannot read properties of undefined (reading 'message')
    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2415:798
    at Array.filter (<anonymous>)
    at Object.renderToolUseProgressMessage (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2415:763)
    at Object.renderToolUseRejectedMessage (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2415:2307)
    at wHB (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2334:1247)
    at aq (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:65:19804)
    at Fy (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:42569)
    at Gy (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38118)
    at IO (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38046)
    at VN (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:37900)

  ERROR  Cannot read properties of undefined (reading 'message')

 file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2415:798

 -  (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2415:798)
 -     at Array.filter (<anonymous>)
 - Object.renderToolUseProgressMessage (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2415:763)
 - Object.renderToolUseRejectedMessage (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2415:2307)
 - wHB (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2334:1247)
 - aq (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:65:19804)
 - Fy (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:42569)
 - Gy (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38118)
 - IO (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38046)
 - VN (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:37900)

Additional Context

The error appears to be in the renderToolUseRejectedMessage function when trying to access the message property of an undefined object during array filtering. This suggests there's a null/undefined handling issue in the tool rejection flow.

View original on GitHub ↗

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