What happened?
When replace falls back to flexible, regex, or fuzzy matching, it can behave too permissively in files that contain very similar functions or blocks.
In the failure case I hit, a file had two highly similar functions and the model was asked to edit one specific function. Because the provided old_string was close but not exact, approximate matching could still select the wrong block instead of failing closed.
That makes a single-target edit risky in cases where two code regions are structurally very similar.
What did you expect to happen?
For single replacements, replace should only succeed when the target is uniquely identified.
Expected behavior:
- If multiple non-exact matches exist and
allow_multiple is not true, the edit should fail with no file changes.
- Fuzzy recovery should tolerate formatting and small punctuation drift, but it should not retarget an edit to a different similarly shaped function with different identifiers.
- Ambiguity handling should be consistent across flexible, regex, and fuzzy strategies.
Client information
Client Information
About Gemini CLI
CLI Version 0.44.0-nightly.20260512.g022e8baef
Git Commit 8cda688fe
Model Auto (Gemini 3)
Sandbox no sandbox
OS win32
Auth Method Signed in with Google
Tier Gemini Code Assist in Google One AI Pro
### Login information
_No response_
### Anything else we need to know?
_No response_
What happened?
When
replacefalls back to flexible, regex, or fuzzy matching, it can behave too permissively in files that contain very similar functions or blocks.In the failure case I hit, a file had two highly similar functions and the model was asked to edit one specific function. Because the provided
old_stringwas close but not exact, approximate matching could still select the wrong block instead of failing closed.That makes a single-target edit risky in cases where two code regions are structurally very similar.
What did you expect to happen?
For single replacements,
replaceshould only succeed when the target is uniquely identified.Expected behavior:
allow_multipleis nottrue, the edit should fail with no file changes.Client information
Client Information