Aider-AI/aider · error · DiffError
Unknown action type encountered: {action.type}
Error message
Unknown action type encountered: {action.type} What it means
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.
Source
Thrown at aider/coders/patch_coder.py:631
if target_path_obj.exists() and full_path != target_full_path:
self.io.tool_warning(
"UPDATE Warning: Target file for move already exists, overwriting:"
f" {action.move_path}"
)
else:
self.io.tool_output(f"Updating {action.path}")
# Ensure parent directory exists for target
target_path_obj.parent.mkdir(parents=True, exist_ok=True)
self.io.write_text(target_full_path, new_content)
# Remove original file *after* successful write to new location if moved
if action.move_path and full_path != target_full_path:
path_obj.unlink()
else:
# Should not happen
raise DiffError(f"Unknown action type encountered: {action.type}")
except (DiffError, FileNotFoundError, IOError, OSError) as e:
# Raise a ValueError to signal failure, consistent with other coders.
raise ValueError(f"Error applying action '{action.type}' to {action.path}: {e}")
except Exception as e:
# Catch unexpected errors during application
raise ValueError(
f"Unexpected error applying action '{action.type}' to {action.path}: {e}"
)
def _apply_update(self, text: str, action: PatchAction, path: str) -> str:
"""
Applies UPDATE chunks to the given text content.
Adapted from _get_updated_file in apply_patch.py.
"""
if action.type is not ActionType.UPDATE:
# Should not be called otherwise, but check for safety
raise DiffError("_apply_update called with non-update action")View on GitHub (pinned to 5dc9490bb3)
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
Example fix
# before apply_edits([PatchAction(type=ActionType.RENAME, path="a")]) # after apply_edits([PatchAction(type=ActionType.UPDATE, path="a", move_path="b", chunks=[...])])
Defensive patterns
Strategy: type-guard
Validate before calling
from aider.coders.patch_coder import ActionType
def only_known_action_types(actions) -> bool:
return all(a.type in (ActionType.ADD, ActionType.DELETE, ActionType.UPDATE) for a in actions) Type guard
from aider.coders.patch_coder import ActionType
HANDLED = {ActionType.ADD, ActionType.DELETE, ActionType.UPDATE}
def is_applicable_action(action) -> bool:
return action.type in HANDLED Try / catch
try:
coder.apply_edits(edits)
except ValueError as e:
if "Unknown action type" in str(e):
edits = [a for a in edits if a.type in HANDLED]
coder.apply_edits(edits)
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: Extending PatchCoder with new action types without updating apply_edits; tests fuzzing the enum; stale pickled/serialized actions across versions.
Related errors
- ADD change for {action.path} has no content
- {path}: Overlapping or out-of-order chunk detected. Current
- Delete File action missing path.
- Delete File Error - file not found: {path}
- Add File action missing path.
AI-assisted analysis of Aider-AI/aider@5dc9490bb3 (2026-08-15).
Data as JSON: /api/errors/9be0ddb9b23402fb.
Report an issue: GitHub.