Skip to content

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

Closed

Description

@takahirom

Environment

  • Platform (select one):
    • Anthropic API
    • AWS Bedrock
    • Google Vertex AI
    • Other:
  • Claude CLI version: 1.0.56 (Claude Code)
  • Operating System: macOS 14.3 (Darwin 24.3.0)
  • Terminal:

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.

Activity

  1. takahirom commented on Jul 24, 2025

    @takahirom
    Author

    This seems to occur only when using Claude hooks. The only hook I'm using is the following:

    {
      "model": "sonnet",
      "hooks": {
        "PreToolUse": [
          {
            "matcher": "",
            "hooks": [
              {
                "type": "command",
                "command": "jq '.' >> /tmp/claude_hooks.jsonl"
              }
            ]
          }
        ]
      }
    }
  2. takahirom commented on Aug 3, 2025

    @takahirom
    Author

    I think this has been fixed. If you have the same problem. Let me know.

  3. github-actions commented on Aug 11, 2025

    @github-actions

    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.

  4. locked as resolved and limited conversation to collaborators on Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions