Aider-AI/aider · error · DiffError

Conflicting actions for file: {path}

Error message

Conflicting actions for file: {path}

What it means

Raised by PatchCoder._parse_patch_text when a second action block references a path that already has an action in patch.actions whose type is not UPDATE — e.g. the patch deletes a file and then tries to update it, or adds it and then updates it. Only UPDATE actions may be merged across repeated blocks.

Source

Thrown at aider/coders/patch_coder.py:333

                # Optional move target
                move_to = None
                if index < len(lines) and _norm(lines[index]).startswith("*** Move to: "):
                    move_to = _norm(lines[index])[len("*** Move to: ") :].strip()
                    index += 1
                    if not move_to:
                        raise DiffError("Move to action missing path.")

                if path not in current_files:
                    raise DiffError(f"Update File Error - missing file content for: {path}")

                file_content = current_files[path]

                existing_action = patch.actions.get(path)
                if existing_action is not None:
                    # Merge additional UPDATE block into the existing one
                    if existing_action.type != ActionType.UPDATE:
                        raise DiffError(f"Conflicting actions for file: {path}")

                    new_action, index, fuzz = self._parse_update_file_sections(
                        lines, index, file_content
                    )
                    existing_action.chunks.extend(new_action.chunks)

                    if move_to:
                        if existing_action.move_path and existing_action.move_path != move_to:
                            raise DiffError(f"Conflicting move targets for file: {path}")
                        existing_action.move_path = move_to
                    fuzz_accumulator += fuzz
                else:
                    # First UPDATE block for this file
                    action, index, fuzz = self._parse_update_file_sections(
                        lines, index, file_content
                    )
                    action.path = path
                    action.move_path = move_to

View on GitHub (pinned to 5dc9490bb3)

Solutions

  1. Split the intent: use '*** Move to:' on the update block for renames, or a single '*** Add File:' for recreate-from-scratch — never combine Delete/Add with Update for the same path in one patch.
  2. Remove the conflicting earlier action for that path.
  3. Re-emit the patch with each file appearing under exactly one action type.
  4. Feed the error back to the LLM so it restructures the patch.

Example fix

# before
*** Delete File: foo.py
*** Update File: foo.py
@@
-a
+b
*** End Patch

# after
*** Update File: foo.py
@@
-a
+b
*** End Patch
Defensive patterns

Strategy: validation

Validate before calling

from collections import defaultdict

def conflicting_file_actions(patch_text: str) -> dict[str, set[str]]:
    acts = defaultdict(set)
    for l in patch_text.splitlines():
        s = l.strip()
        for kind, marker in (("ADD", "*** Add File: "), ("DEL", "*** Delete File: "), ("UPD", "*** Update File: ")):
            if s.startswith(marker):
                acts[s[len(marker):].strip()].add(kind)
    return {p: k for p, k in acts.items() if len(k) > 1}  # non-empty → restructure before applying

Try / catch

try:
    coder.get_edits(patch_text)
except ValueError as e:
    if "Conflicting actions for file:" in str(e):
        path = str(e).split("Conflicting actions for file:")[-1].strip()
        patch_text = drop_conflicting_action(patch_text, path)  # keep exactly one action type
        coder.get_edits(patch_text)
    else:
        raise

Prevention

When it happens

Trigger: A single patch containing '*** Delete File: foo.py' (or '*** Add File: foo.py') followed later by '*** Update File: foo.py' — the existing_action.type check (≠ ActionType.UPDATE) trips and raises.

Common situations: Models emitting delete-then-recreate sequences as delete+update instead of a single Add or Move; long patches where the model loses track of which files it already handled; hallucinated duplicate file sections.

Related errors


AI-assisted analysis of Aider-AI/aider@5dc9490bb3 (2026-08-15). Data as JSON: /api/errors/1d73f15f20b1d442. Report an issue: GitHub.