`apply_patch` accidentally deletes files when `*** Move to:` is present
Resolved 💬 2 comments Opened Nov 7, 2025 by aegonwolf Closed Jan 24, 2026
What version of Codex is running?
0.55.0
What subscription do you have?
Pro
Which model were you using?
GPT-5
What platform is your computer?
Windows
What issue are you seeing?
## Summary
While editing diary.md via the Codex CLI built-in edit tool, the file was unexpectedly deleted after applying a patch. The command succeeded, but
diary.md vanished from the repo—git status reported it as deleted.
## Steps to Reproduce
- Open any repository in the Codex CLI.
- Run an
apply_patchedit that begins with*** Update File: diary.mdbut also includes the line*** Move to: diary.md(likely copied from a
previous multi-file patch).
- Apply the patch.
- Inspect the filesystem or run
git status.
## Actual Behavior
- The patch command reports success.
- The target file is deleted from the working tree (Git marks it as removed).
## Suggested Fix
- Validate that a
*** Move to:directive isn’t pointing back to the same filename unless accompanied by a proper change block; otherwise, reject the
patch.
- Alternatively, ensure that a “move” without new content doesn’t delete the source file.
Let me know if you want any adjustments before submitting the issue or if there’s anything else for the portal.
What steps can reproduce the bug?
## Steps to Reproduce
- Open any repository in the Codex CLI.
- Run an
apply_patchedit that begins with*** Update File: diary.mdbut also includes the line*** Move to: diary.md(likely copied from a
previous multi-file patch).
- Apply the patch.
- Inspect the filesystem or run `git status
What is the expected behavior?
## Expected Behavior
apply_patchshould either reject the malformed directive or leave the file untouched.- At minimum, the tool should emit an error/warning instead of removing the file silently.
Additional information
I let codex write this issue itself
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗