Aider-AI/aider · error · DiffError
Delete File Error - file not found: {path}
Error message
Delete File Error - file not found: {path} What it means
Thrown when a '*** Delete File: <path>' targets a path not present in current_files — the files aider has in chat context. The parser validates deletes against known files because it has no other way to confirm the target exists. It prevents deleting files the coder never saw.
Source
Thrown at aider/coders/patch_coder.py:371
fuzz_accumulator += fuzz
continue
# ---------- DELETE ---------- #
elif norm_line.startswith("*** Delete File: "):
path = norm_line[len("*** Delete File: ") :].strip()
index += 1
if not path:
raise DiffError("Delete File action missing path.")
existing_action = patch.actions.get(path)
if existing_action:
if existing_action.type == ActionType.DELETE:
# Duplicate delete – ignore the extra block
self.io.tool_warning(f"Duplicate delete action for file: {path} ignored.")
continue
else:
raise DiffError(f"Conflicting actions for file: {path}")
if path not in current_files:
raise DiffError(
f"Delete File Error - file not found: {path}"
) # Check against known files
patch.actions[path] = PatchAction(type=ActionType.DELETE, path=path)
continue
# ---------- ADD ---------- #
elif norm_line.startswith("*** Add File: "):
path = norm_line[len("*** Add File: ") :].strip()
index += 1
if not path:
raise DiffError("Add File action missing path.")
if path in patch.actions:
raise DiffError(f"Duplicate action for file: {path}")
# Check if file exists in the context provided (should not for Add).
# Note: We only have needed files, a full check requires FS access.
# if path in current_files:
# raise DiffError(f"Add File Error - file already exists: {path}")View on GitHub (pinned to 5dc9490bb3)
Solutions
- Add the file to the chat (e.g. /add path/to/file) so it appears in current_files, then re-apply the patch
- Correct the path in the patch to exactly match the chat file's relative path
- If the file genuinely doesn't need to exist in chat, delete it manually with rm/git rm instead of via the patch
Example fix
# before (file not in chat) *** Delete File: unused.py # after /add unused.py # then re-apply the patch containing: *** Delete File: unused.py
Defensive patterns
Strategy: validation
Validate before calling
def deletes_in_chat(patch_text: str, chat_files: set[str]) -> list[str]:
missing = []
for line in patch_text.splitlines():
if line.startswith("*** Delete File: "):
p = line[len("*** Delete File: "):].strip()
if p not in chat_files:
missing.append(p)
return missing # empty list means safe Try / catch
try:
edits = coder.get_edits(reply)
except DiffError as e:
if "Delete File Error - file not found" in str(e):
for f in extract_deleted_paths(reply):
coder.commands.cmd_add(f) # bring file into chat
edits = coder.get_edits(reply)
else:
raise Prevention
- /add every file you intend the model to modify or delete
- Keep the model's file list (chat files) in sync with the actual change set
- Prefer matching the exact relative paths shown in the chat summary
When it happens
Trigger: Patch deletes a file that was never added to the chat (not in current_files); path casing or spelling differs from the chat file's path; deleting a file the model hallucinated.
Common situations: User asks to delete a file they never /added; model guesses a filename; path normalization mismatches (leading './', different separators) between the patch and the chat file list.
Related errors
- UPDATE Error: File does not exist: {action.path}
- File referenced in patch not found: {rel_path}
- Delete File action missing path.
- Add File action missing path.
- Duplicate action for file: {path}
AI-assisted analysis of Aider-AI/aider@5dc9490bb3 (2026-08-15).
Data as JSON: /api/errors/d12ac0bf040a52f1.
Report an issue: GitHub.