[BUG]
Environment
- Platform (select one):
- Anthropic API
- AWS Bedrock
- Google Vertex AI
- Other:
- Claude CLI version: 1.0.60 (Claude Code)
- Operating System: Windows 11
- Terminal: Command Prompt/PowerShell
Bug Description
Claude Code crashes with "String not found in file. Failed to apply edit" error when attempting to edit a file using the Edit tool. The error occurs during file editing operations and
causes the entire CLI to terminate with an uncaught exception.
Steps to Reproduce
- Use Claude Code to edit a file (in this case Korneev_Alexander_CV.md)
- Attempt to apply an edit using the Edit tool
- The edit fails with "String not found in file" error
- CLI crashes with Node.js uncaught exception
Expected Behavior
When an edit fails due to string not being found, Claude Code should:
- Handle the error gracefully without crashing
- Provide clear feedback about why the edit failed
- Allow the user to continue the session
Actual Behavior
The CLI crashes completely with this error stack trace:
node:internal/process/promises:394
triggerUncaughtException(err, true / fromPromise /);
^
Error: String not found in file. Failed to apply edit.
at zx (file:///C:/Users/Inter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1787:728)
at xV8 (file:///C:/Users/Inter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:2716:11114)
at J (file:///C:/Users/Inter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:2716:10092)
at file:///C:/Users/Inter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:2716:10358
at LF (file:///C:/Users/Inter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:67:21533)
at HX (file:///C:/Users/Inter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:67:41153)
at file:///C:/Users/Inter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:67:39325
at mc1 (file:///C:/Users/Inter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:61:78952)
at Immediate.xc1 [as _onImmediate] (file:///C:/Users/Inter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:61:79371)
at process.processImmediate (node:internal/timers:485:21)
Node.js v22.17.1
Additional Context
- The error appears to be an unhandled promise rejection that should be caught and handled gracefully
- This affects user experience as it terminates the entire session
- The underlying edit failure might be valid (string not found), but the crash is not acceptable behavior
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗