{"record":{"id":"d957b04ccad2c94a","repo":"Aider-AI/aider","slug":"update-error-file-does-not-exist-action-path","errorCode":null,"errorMessage":"UPDATE Error: File does not exist: {action.path}","messagePattern":"UPDATE Error: File does not exist: (.+?)","errorType":"exception","errorClass":"DiffError","httpStatus":null,"severity":"error","filePath":"aider/coders/patch_coder.py","lineNumber":593,"sourceCode":"                    path_obj.parent.mkdir(parents=True, exist_ok=True)\n                    # Ensure single trailing newline, matching reference behavior\n                    content_to_write = action.new_content\n                    if not content_to_write.endswith(\"\\n\"):\n                        content_to_write += \"\\n\"\n                    self.io.write_text(full_path, content_to_write)\n\n                elif action.type == ActionType.DELETE:\n                    self.io.tool_output(f\"Deleting {action.path}\")\n                    if not path_obj.exists():\n                        self.io.tool_warning(\n                            f\"DELETE Warning: File not found, skipping: {action.path}\"\n                        )\n                    else:\n                        path_obj.unlink()\n\n                elif action.type == ActionType.UPDATE:\n                    if not path_obj.exists():\n                        raise DiffError(f\"UPDATE Error: File does not exist: {action.path}\")\n\n                    current_content = self.io.read_text(full_path)\n                    if current_content is None:\n                        # Should have been caught during parsing if file was needed\n                        raise DiffError(f\"Could not read file for UPDATE: {action.path}\")\n\n                    # Apply the update logic using the parsed chunks\n                    new_content = self._apply_update(current_content, action, action.path)\n\n                    target_full_path = (\n                        self.abs_root_path(action.move_path) if action.move_path else full_path\n                    )\n                    target_path_obj = pathlib.Path(target_full_path)\n\n                    if action.move_path:\n                        self.io.tool_output(\n                            f\"Updating and moving {action.path} to {action.move_path}\"\n                        )","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/Aider-AI/aider/blob/5dc9490bb35f9729ef2c95d00a19ccd30c26339c/aider/coders/patch_coder.py#L575-L611","documentation":"Application-time failure: an UPDATE action targets a file that does not exist on disk. Unlike DELETE (which warns and skips), UPDATE is strict — there is nothing to apply chunks against, so it raises and the whole apply is wrapped into a ValueError.","triggerScenarios":"File was deleted or renamed after the patch was parsed; UPDATE path has a typo/casing mismatch; patch generated against a branch where the file exists but applied in a worktree where it doesn't.","commonSituations":"git branch/worktree switches mid-session; files removed by another tool; case-sensitive filesystem exposing path casing bugs.","solutions":["Restore or recreate the file, or switch to the branch/worktree where it exists","Fix the path in the patch to the actual file location","If the intent is creating new content, change the action to '*** Add File:'"],"exampleFix":"# before\n*** Update File: renamed_module.py\n\n# after (file was renamed)\n*** Update File: src/renamed_module.py\n","handlingStrategy":"validation","validationCode":"import os\n\ndef update_targets_exist(actions) -> list[str]:\n    return [a.path for a in actions\n            if a.type.name == \"UPDATE\" and not os.path.exists(os.path.join(ROOT, a.path))]","typeGuard":null,"tryCatchPattern":"try:\n    coder.apply_edits(edits)\nexcept ValueError as e:\n    if \"UPDATE Error: File does not exist\" in str(e):\n        raise RuntimeError(f\"file missing; check branch/worktree: {e}\")\n    raise","preventionTips":["Verify the working tree/branch matches what the patch was generated against","Check exact path spelling and case before applying","Use Add (not Update) for files that should be created"],"tags":["aider","patch","update","file-not-found"],"backgroundTag":null,"analyzedSha":"5dc9490bb35f9729ef2c95d00a19ccd30c26339c","analyzedAt":"2026-08-15T05:40:10.498Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}