{"record":{"id":"99ec75d74b026dc4","repo":"Aider-AI/aider","slug":"add-file-action-missing-path","errorCode":null,"errorMessage":"Add File action missing path.","messagePattern":"Add File action missing path\\.","errorType":"exception","errorClass":"DiffError","httpStatus":null,"severity":"error","filePath":"aider/coders/patch_coder.py","lineNumber":383,"sourceCode":"                        # Duplicate delete – ignore the extra block\n                        self.io.tool_warning(f\"Duplicate delete action for file: {path} ignored.\")\n                        continue\n                    else:\n                        raise DiffError(f\"Conflicting actions for file: {path}\")\n                if path not in current_files:\n                    raise DiffError(\n                        f\"Delete File Error - file not found: {path}\"\n                    )  # Check against known files\n\n                patch.actions[path] = PatchAction(type=ActionType.DELETE, path=path)\n                continue\n\n            # ---------- ADD ---------- #\n            elif norm_line.startswith(\"*** Add File: \"):\n                path = norm_line[len(\"*** Add File: \") :].strip()\n                index += 1\n                if not path:\n                    raise DiffError(\"Add File action missing path.\")\n                if path in patch.actions:\n                    raise DiffError(f\"Duplicate action for file: {path}\")\n                # Check if file exists in the context provided (should not for Add).\n                # Note: We only have needed files, a full check requires FS access.\n                # if path in current_files:\n                #     raise DiffError(f\"Add File Error - file already exists: {path}\")\n\n                action, index = self._parse_add_file_content(lines, index)\n                action.path = path  # Ensure path is set\n                patch.actions[path] = action\n                continue\n\n            # If we are here, the line is unexpected\n            # Allow blank lines between actions\n            if not norm_line.strip():\n                index += 1\n                continue\n","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/Aider-AI/aider/blob/5dc9490bb35f9729ef2c95d00a19ccd30c26339c/aider/coders/patch_coder.py#L365-L401","documentation":"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.","triggerScenarios":"Model output contains '*** Add File: ' with a blank filename, or the header was truncated by a token/streaming limit before the filename was emitted.","commonSituations":"Output truncation near max_tokens; models unfamiliar with the patch format omitting the filename; whitespace-only paths from sloppy prompt templates.","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"],"exampleFix":"// before\n*** Add File: \n+content\n\n// after\n*** Add File: src/new_module.py\n+content\n","handlingStrategy":"validation","validationCode":"import re\nADD_HDR = re.compile(r\"^\\*\\*\\* Add File: (.+)$\")\n\ndef add_headers_valid(patch_text: str) -> bool:\n    return all(ADD_HDR.match(l) is not None\n               for l in patch_text.splitlines()\n               if l.startswith(\"*** Add File\"))","typeGuard":null,"tryCatchPattern":"try:\n    edits = coder.get_edits(reply)\nexcept DiffError as e:\n    if \"Add File action missing path\" in str(e):\n        edits = coder.get_edits(regenerate_patch(reply))\n    else:\n        raise","preventionTips":["Show a well-formed Add File example in the prompt","Watch for truncated model output near token limits","Validate '*** ' headers programmatically before parsing"],"tags":["aider","patch","parsing","llm-output"],"backgroundTag":null,"analyzedSha":"5dc9490bb35f9729ef2c95d00a19ccd30c26339c","analyzedAt":"2026-08-15T05:40:10.498Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}