anomalyco / anomalyco/opencode

tool/edit: stale-content error mentions "permission approval" though any concurrent write triggers it

Open
#48,707 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Sep 12, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

edit reports File changed after permission approval. Read it again before editing. whenever FileMutation.StaleContentError fires, but that error is raised whenever the file's bytes differ from what the tool read — for example when another session or process writes the file during the edit's read→write window. The message misattributes the cause to the permission flow, which is confusing when debugging concurrent edits.

Environment

  • opencode version: 2.0.2
  • OS: Windows 11 (10.0.26220.9343, win32 x64)
  • Terminal: Unavailable: reproduced against the background service
  • Shell: cmd.exe
  • Install/channel: latest (2.0.2)
  • Active plugins: 4 local entries auto-discovered from ~/.config/opencode/plugins/

Reproduction

  1. Start an edit on a file whose content another writer changes concurrently (same path, any session or process).
  2. The store's compare-and-swap detects the mismatch and edit fails with: File changed after permission approval. Read it again before editing.
  3. No permission approval was involved in the failing mutation.

Expected Behavior

A message that names the actual condition, e.g. File changed since it was read. Read it again before editing.

Actual Behavior

File changed after permission approval. Read it again before editing.

Additional Context

  • Source: packages/core/src/tool/edit.ts maps FileMutation.StaleContentError to this message; packages/core/src/file-mutation.ts raises it when the expected bytes differ from the current bytes under the per-path lock.
  • Impact is low — the message still tells the reader to re-read — but the stated reason is misleading in the common concurrent-write case.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.