Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
Description
The edit tool reports Could not find oldString ... It must match exactly, including whitespace and indentation for oldString values that match the file exactly, whenever they contain leading indentation (multi-space runs) or backslash sequences. Only single-line oldString values with zero or one leading space match. This blocked all real edits to one working file.
Environment
- opencode version: v2.0.22
- OS: Linux Sicily 7.2.8-2-cachyos x86_64 GNU/Linux
- Terminal: TERM=xterm-256color, TERM_PROGRAM unset, COLORTERM unset
- Shell: /bin/fish
- Install/channel: latest
- Active plugins: no
pluginentries in~/.config/opencode/opencode.json; MCP serverphoton(local) configured; runtime snapshot also listedopencode.browser,openchamber-agent-tool
Reproduction
- Create a JSON file with 4-space indented lines, e.g. a line
"cmd": 847,. - Call
editwitholdString="cmd": 847,(exact, 4-space indent) and a differingnewString(e.g. trailing space). - Observe the error
Could not find oldString in <file>. It must match exactly, including whitespace and indentation. - Retry with
oldString="cmd": 847,(no indent) and the same change → the edit succeeds (Edited <file> (1 replacement)). - Retry with
oldString="cmd": 847,(one leading space) → also succeeds.
Expected Behavior
An oldString that byte-matches the file content, including its exact leading whitespace, should match regardless of indentation width.
Actual Behavior
- Any
oldStringcontaining a multi-space leading run (tested: 2, 3, 4 spaces; tab) is reported as not found, while 0/1-space variants of the same content match as substrings. - Multiline
oldStringvalues spanning indented lines fail the same way, making it impossible to target JSON values (e.g."es": "") that need surrounding lines for uniqueness. oldStringvalues containing backslash sequences (e.g."en": "\\E\\f[27]Misa Kaji",) also fail; backslash-free fragments of the same lines succeed, so this may share the root cause.- Sanity check: identical
oldString/newStringreturnsNo changes to apply: oldString and newString are identical, which suggests the mismatch happens in the real search path, not in parameter transport of the content itself.
Additional Context
- Frequency: consistent throughout the session for one ~90 KB JSON batch file (
ESP/work/common/evt_466.json, 2190 lines, LF endings, space indentation confirmed viagrep ^[ ]matching level-1 keys). - Edits to another file (
ESP/glossary.md, lines containing only single spaces) worked fine in the same session, pointing at whitespace-run handling rather than a general tool outage. - Possibly related:
greppatterns with{n}quantifiers (e.g.^[ ]{4}"cmd") returned no matches while equivalent single-character patterns (^[ ]) matched; tab pattern^\talso matched nothing. - Workaround used: single-line, unindented substring edits only. No workaround exists for edits that require indented multiline context.
- Impact: blocked a 312-item file batch (logged as blocked in project notes); no data was corrupted (all probe edits reverted and verified).
Metadata
Metadata
Assignees
Labels
No labels
Activity
ChrisTVH commentedon Oct 3, 2026
Closing as duplicate of #52067, which covers the same tool whitespace-matching failures. The deterministic indentation repro from this issue (v2.0.22, indented consistently not found while unindented variants match) is preserved here for reference.
ChrisTVH commentedon Oct 3, 2026
Correction of the close comment above (backticks were swallowed by shell expansion): Closing as duplicate of #52067, which covers the same edit tool whitespace-matching failures. The deterministic indentation repro from this issue (v2.0.22, indented oldString consistently not found while unindented variants match) is preserved here for reference.
github-actions commentedon Oct 3, 2026
Thanks for updating the issue. The bug report now includes a clear description and reproduction steps.