Skip to content

fix(opencode): clarify edit not-found error to reflect fuzzy fallbacks - #45092

Open
arpankanwer wants to merge 1 commit into
anomalyco:devfrom
arpankanwer:fix/44996-edit-error-message
Open

fix(opencode): clarify edit not-found error to reflect fuzzy fallbacks#45092
arpankanwer wants to merge 1 commit into
anomalyco:devfrom
arpankanwer:fix/44996-edit-error-message

Conversation

@arpankanwer

@arpankanwer arpankanwer commented Aug 25, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #44996

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The edit tool reported exact whitespace matching was required, but replace() in packages/opencode/src/tool/edit.ts tries 8 fuzzy replacers (LineTrimmedReplacer, WhitespaceNormalizedReplacer, IndentationFlexibleReplacer, etc.) before failing. The error text misled callers to re-check whitespace that would already have been tolerated.

Changed only the not-found throw at edit.ts:725 to state that exact and fuzzy fallbacks were attempted and to re-read the file. The second throw for multiple matches was left unchanged.

How did you verify your code works?

  • Read edit.ts around L720-730 and confirmed the new string.
  • Checked packages/opencode/test/tool/edit.test.ts uses toContain("Could not find oldString") so existing tests stay compatible.
  • Manually inspected the replacer chain at L694-704 to confirm whitespace normalization.

Screenshots / recordings

N/A — string change only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The error claimed exact whitespace matching was required, but the
replacer chain normalizes whitespace, indentation and escapes before
failing. Update the message to state that exact and fuzzy fallbacks
were attempted and guide callers to re-read the file.

Fixes anomalyco#44996
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@arpankanwer
arpankanwer marked this pull request as ready for review August 25, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

edit: not-found error claims exact whitespace matching, but matching normalizes whitespace

1 participant