Skip to content

[BUG]: edit tool error message recommends write tool (which has no stale-content check) #30769

Closed

Description

Description

When the AI passes an empty oldString to the edit tool, edit.ts:127-131 returns:

"oldString must not be empty. Use write to create or overwrite a file."

This error message directs AI to use write — the one mutation tool that has no stale-content check (see #30765). Write silently overwrites any file without verifying the AI has read it or that content hasn't changed.

This creates a perverse self-reinforcing loop:

  1. Edit tool (has protection) rejects empty oldString — correct
  2. Edit tool tells AI to use Write (no protection) — unsafe
  3. AI uses Write, file gets overwritten without any checks

The error message should suggest reading the file first and retrying with exact content, not punting to the unsafe tool.

Chain from #30376 and #30765.

Plugins

N/A (source code analysis)

OpenCode version

main

Steps to reproduce

  1. AI tries to edit a file with empty oldString
  2. Gets told to use write instead
  3. write overwrites file without stale-content check

Screenshot and/or share link

N/A (we read the source code)

Operating System

N/A (code analysis, not environment-specific)

Terminal

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions