{"record":{"id":"9be0ddb9b23402fb","repo":"Aider-AI/aider","slug":"unknown-action-type-encountered-action-type","errorCode":null,"errorMessage":"Unknown action type encountered: {action.type}","messagePattern":"Unknown action type encountered: (.+?)","errorType":"exception","errorClass":"DiffError","httpStatus":null,"severity":"error","filePath":"aider/coders/patch_coder.py","lineNumber":631,"sourceCode":"                        if target_path_obj.exists() and full_path != target_full_path:\n                            self.io.tool_warning(\n                                \"UPDATE Warning: Target file for move already exists, overwriting:\"\n                                f\" {action.move_path}\"\n                            )\n                    else:\n                        self.io.tool_output(f\"Updating {action.path}\")\n\n                    # Ensure parent directory exists for target\n                    target_path_obj.parent.mkdir(parents=True, exist_ok=True)\n                    self.io.write_text(target_full_path, new_content)\n\n                    # Remove original file *after* successful write to new location if moved\n                    if action.move_path and full_path != target_full_path:\n                        path_obj.unlink()\n\n                else:\n                    # Should not happen\n                    raise DiffError(f\"Unknown action type encountered: {action.type}\")\n\n            except (DiffError, FileNotFoundError, IOError, OSError) as e:\n                # Raise a ValueError to signal failure, consistent with other coders.\n                raise ValueError(f\"Error applying action '{action.type}' to {action.path}: {e}\")\n            except Exception as e:\n                # Catch unexpected errors during application\n                raise ValueError(\n                    f\"Unexpected error applying action '{action.type}' to {action.path}: {e}\"\n                )\n\n    def _apply_update(self, text: str, action: PatchAction, path: str) -> str:\n        \"\"\"\n        Applies UPDATE chunks to the given text content.\n        Adapted from _get_updated_file in apply_patch.py.\n        \"\"\"\n        if action.type is not ActionType.UPDATE:\n            # Should not be called otherwise, but check for safety\n            raise DiffError(\"_apply_update called with non-update action\")","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/Aider-AI/aider/blob/5dc9490bb35f9729ef2c95d00a19ccd30c26339c/aider/coders/patch_coder.py#L613-L649","documentation":"Unreachable-state guard at the end of apply_edits()'s dispatch chain: a PatchAction whose type is neither ADD, DELETE, nor UPDATE. It marks internal inconsistency — the ActionType enum gained a member or an action was built with an invalid type.","triggerScenarios":"Constructing PatchAction with a new/invalid ActionType value and passing it to apply_edits; enum refactors where a variant (e.g. MOVE as standalone) isn't handled in this dispatcher.","commonSituations":"Extending PatchCoder with new action types without updating apply_edits; tests fuzzing the enum; stale pickled/serialized actions across versions.","solutions":["Handle the new ActionType in apply_edits's if/elif chain (or filter such actions before calling)","Validate action.type against a known set before invoking apply_edits","Regenerate/reparse actions if they came from an older serialized format"],"exampleFix":"# before\napply_edits([PatchAction(type=ActionType.RENAME, path=\"a\")])\n\n# after\napply_edits([PatchAction(type=ActionType.UPDATE, path=\"a\", move_path=\"b\", chunks=[...])])\n","handlingStrategy":"type-guard","validationCode":"from aider.coders.patch_coder import ActionType\n\ndef only_known_action_types(actions) -> bool:\n    return all(a.type in (ActionType.ADD, ActionType.DELETE, ActionType.UPDATE) for a in actions)","typeGuard":"from aider.coders.patch_coder import ActionType\n\nHANDLED = {ActionType.ADD, ActionType.DELETE, ActionType.UPDATE}\n\ndef is_applicable_action(action) -> bool:\n    return action.type in HANDLED","tryCatchPattern":"try:\n    coder.apply_edits(edits)\nexcept ValueError as e:\n    if \"Unknown action type\" in str(e):\n        edits = [a for a in edits if a.type in HANDLED]\n        coder.apply_edits(edits)\n    else:\n        raise","preventionTips":["Update apply_edits's dispatch when adding ActionType members","Filter actions to the handled set before calling apply_edits","Don't feed actions deserialized from older formats into a newer coder"],"tags":["aider","patch","invariant","enum"],"backgroundTag":null,"analyzedSha":"5dc9490bb35f9729ef2c95d00a19ccd30c26339c","analyzedAt":"2026-08-15T05:40:10.498Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}