[BUG] Fails to apply multiple changes to markdown file

Resolved 💬 3 comments Opened Jun 10, 2025 by torbjornjohannsen Closed Jul 25, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.17 (Claude Code)
  • Operating System: Debian 12
  • Terminal: vscode, v1.0.17

Bug Description

Claude in the vscode extension is asked to change the second sentence in 28 cold email drafts. It reads the correct file but then produces the following stacktrace while opening the change approval box; but no file/changes are shown in vscode.

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:
Error: String not found in file. Failed to apply edit.
    at wO (file:///home/tb/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1610:546)
    at rY5 (file:///home/tb/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1921:10189)
    at J (file:///home/tb/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1921:9167)
    at file:///home/tb/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1921:9433
    at r7 (file:///home/tb/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:21374)
    at eD (file:///home/tb/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:40861)
    at file:///home/tb/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:39057
    at Tk1 (file:///home/tb/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:138:163063)
    at Immediate.Nk1 [as _onImmediate] (file:///home/tb/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:138:163481)
    at process.processImmediate (node:internal/timers:491:21)

Steps to Reproduce

  1. Clear context
  2. Give claude the prompt "Replace the second sentence in all 28 emails in the file some/folder/Emails.md with this sentece "Second sentence"
  3. Thinks for 20-30s then fails as described.

Expected Behavior

Claude would (hopefully) correctly parse what the second sentence is in each email and replace it. Or at least change something instead of crashing.

Actual Behavior

The CLI pretends it's presenting changes, prints the stack-trace above(which disappears if you toggle cltr+r) and gives you the dialog box to accept the changes.

Additional Context

In the CLI it will present you with the accept change dialog, showing the correct changes. But then if you accept it just says

● Update(some/folder/Emails.md)
  ⎿  Error: String not found in file. Failed to apply edit.

View original on GitHub ↗

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