[BUG] Unhandled Promise Rejection: 'Bad substitution: re.test' Error in Non-interactive Mode
Resolved 💬 4 comments Opened Apr 9, 2025 by amaruy Closed May 8, 2025
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [x] Other: Claude Code CLI
- Claude CLI version: 0.2.66 (Claude Code)
- Operating System: Ubuntu 24.04.2 LTS
- Terminal: Bash
Bug Description
While running Claude Code in non-interactive mode, encountered an unhandled promise rejection with the error "Bad substitution: re.test" which appears to be related to regular expression handling.
Steps to Reproduce
- Ran Claude Code in non-interactive mode (python script):
cmd = f"claude -p --verbose --output-format stream-json --dangerously-skip-permissions @claude_prompt.txt >> '{transcript_path}'"
subprocess.run(cmd, shell=True, timeout=CLAUDE_TIMEOUT, check=False)
- Unfortunately, i cannot directly recreate the prompt.
Expected Behavior
Command should complete successfully without unhandled promise rejections.
Actual Behavior
Received an unhandled promise rejection with the following stack trace:
Error: Bad substitution: re.test
at U (file:///home/ubuntu/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:52:10745)
at file:///home/ubuntu/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:52:11404
at Array.map (<anonymous>)
at $O4 (file:///home/ubuntu/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:52:10483)
at Object.I (file:///home/ubuntu/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:52:11568)
at TU (file:///home/ubuntu/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:822:717)
at Object.isReadOnly (file:///home/ubuntu/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1125:2904)
at file:///home/ubuntu/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1562:2475
at Array.reduce (<anonymous>)
at bv1 (file:///home/ubuntu/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1562:2398)This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗