Aider-AI/aider · error · DiffError
Add File action missing path.
Error message
Add File action missing path.
What it means
Parser error from PatchCoder when an '*** Add File:' header line carries no path. Symmetric to the Delete variant: the text after the prefix must be a non-empty path before an ADD PatchAction can be created.
Source
Thrown at aider/coders/patch_coder.py:383
# 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}")
action, index = self._parse_add_file_content(lines, index)
action.path = path # Ensure path is set
patch.actions[path] = action
continue
# If we are here, the line is unexpected
# Allow blank lines between actions
if not norm_line.strip():
index += 1
continue
View on GitHub (pinned to 5dc9490bb3)
Solutions
- Regenerate with a complete '*** Add File: <relative/path>' header
- Raise the model's max output tokens if truncation is the cause
- Pre-validate patch headers programmatically before handing text to PatchCoder
Example fix
// before *** Add File: +content // after *** Add File: src/new_module.py +content
Defensive patterns
Strategy: validation
Validate before calling
import re
ADD_HDR = re.compile(r"^\*\*\* Add File: (.+)$")
def add_headers_valid(patch_text: str) -> bool:
return all(ADD_HDR.match(l) is not None
for l in patch_text.splitlines()
if l.startswith("*** Add File")) Try / catch
try:
edits = coder.get_edits(reply)
except DiffError as e:
if "Add File action missing path" in str(e):
edits = coder.get_edits(regenerate_patch(reply))
else:
raise Prevention
- Show a well-formed Add File example in the prompt
- Watch for truncated model output near token limits
- Validate '*** ' headers programmatically before parsing
When it happens
Trigger: Model output contains '*** Add File: ' with a blank filename, or the header was truncated by a token/streaming limit before the filename was emitted.
Common situations: Output truncation near max_tokens; models unfamiliar with the patch format omitting the filename; whitespace-only paths from sloppy prompt templates.
Related errors
- Delete File action missing path.
- Bad/missing filename. The filename must be alone on the line
- Expected `=======`
- Expected `>>>>>>> REPLACE` or `=======`
- Duplicate action for file: {path}
AI-assisted analysis of Aider-AI/aider@5dc9490bb3 (2026-08-15).
Data as JSON: /api/errors/99ec75d74b026dc4.
Report an issue: GitHub.