[BUG] Error: Found 2 matches of the string to replace, but replace_all is false.

Resolved 💬 21 comments Opened Jul 11, 2025 by nullbio Closed Jan 6, 2026

I get this red colored error happen a lot. Is there something I need to do to fix this?

● Update(run.py)
  ⎿  Error: Found 2 matches of the string to replace, but replace_all is false. To replace all occurrences, set replace_all to true. To replace only one occurrence, please
     provide more context to uniquely identify the instance.
     String:         <string here>

View original on GitHub ↗

21 Comments

nevercast · 1 year ago

I would expect Claude to recover itself from this, it happens when the file is large or contains many lines of code that are similar to each other. Claude will try to Read more of the file and adjust its Update request to correctly identify the specific piece of code to change, but it may struggle if there are many pieces that are similar or identical.

For ways you could help Claude, consider breaking your code into multiple files that contain unique behaviour. You could even ask Claude to identify parts of the code that seem duplicated in functionality, or literal code, that could be safely modularised.

LittleMaxi · 1 year ago

+1

ariesdeparture · 12 months ago

+1

cyreb7 · 12 months ago

My Claude was trying to find and replace a set of strings in a file, so it tried and failed to use MultiEdit twice before giving up and resorting to sed instead:

✻ Thinking…

  Let me fix all the occurrences of asyncRenderString in this test file. I'll use MultiEdit to make all the changes at
   once:

● Update(__tests__/general/formTest.js)
  ⎿  Error: Found 2 matches of the string to replace, but replace_all is false. To replace all occurrences, set 
     replace_all to true. To replace only one occurrence, please provide more context to uniquely identify the 
     instance.
     String:     it("logs an error if path isn't an array.", async function () {

✻ Thinking…

  Let me fix this by being more specific about the instances:

● Update(__tests__/general/formTest.js)
  ⎿  Error: Found 2 matches of the string to replace, but replace_all is false. To replace all occurrences, set 
     replace_all to true. To replace only one occurrence, please provide more context to uniquely identify the 
     instance.
     String:   it("Works with multiple forms", async function () {

✻ Thinking…

  Let me run the tests to see if we have the issue fixed with what we've changed so far. I'll need to make sure all 
  the async related changes are done:

● Bash(sed -i 's/await nunjucks\.asyncRenderString/nunjucks.renderString/g'
      /workspace/apps/__tests__/general/formTest.js)
  ⎿  Running…
Ale1x · 11 months ago

+1

cotovanu-cristian · 11 months ago

+1

harvey-propelle · 11 months ago

+1

mechanin · 11 months ago

+1

jqhr · 11 months ago

+1

seanGSISG · 11 months ago

+1 it recovered but it would be nice if was something we could enabled instead of claude code having to do 20+ different edits of the same thing

alexandrosk · 11 months ago

+1

onurku · 11 months ago

+1

farishrf · 11 months ago

+1

Th0rGarden · 11 months ago

I don't understand how anyone is using claude code when it literally does this multiple times a session. Is everyone "using" claude code just faking it? this is unusable in its current state.

You're telling me that of all AI products, Claude Code runs into literal errors doing multiple replacements?

Its entire purpose is editing files like this!

Is this a joke? Or are we doing something wrong? How does anyone actually use this tool if it constantly runs into issues with multiple replacements? Every basic AI coding tool out there can do this.

FYZAFH · 10 months ago

+1, but it will resume soon

Th0rGarden · 10 months ago

No response, no resolution, nothing. Anthropic is an embarrassment. If Claude Code of all tools can't do multiple replacements without running into errors all the time then Anthropic is a pure fraud company.

github-actions[bot] · 7 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

Th0rGarden · 7 months ago

I left claude code because of this mess. Is this still a problem?

FYZAFH · 7 months ago
I left claude code because of this mess. Is this still a problem?

no @Th0rGarden

github-actions[bot] · 6 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 6 months ago

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.