{"record":{"id":"9ffa543a78713258","repo":"Aider-AI/aider","slug":"unknown-edit-format-edit-format-valid-formats-a","errorCode":null,"errorMessage":"Unknown edit format {edit_format}. Valid formats are: {', '.join(valid_formats)}","messagePattern":"Unknown edit format (.+?)\\. Valid formats are: (.+?)","errorType":"exception","errorClass":"UnknownEditFormat","httpStatus":null,"severity":"error","filePath":"aider/coders/base_coder.py","lineNumber":201,"sourceCode":"            )\n            use_kwargs.update(update)  # override to complete the switch\n            use_kwargs.update(kwargs)  # override passed kwargs\n\n            kwargs = use_kwargs\n            from_coder.ok_to_warm_cache = False\n\n        for coder in coders.__all__:\n            if hasattr(coder, \"edit_format\") and coder.edit_format == edit_format:\n                res = coder(main_model, io, **kwargs)\n                res.original_kwargs = dict(kwargs)\n                return res\n\n        valid_formats = [\n            str(c.edit_format)\n            for c in coders.__all__\n            if hasattr(c, \"edit_format\") and c.edit_format is not None\n        ]\n        raise UnknownEditFormat(edit_format, valid_formats)\n\n    def clone(self, **kwargs):\n        new_coder = Coder.create(from_coder=self, **kwargs)\n        return new_coder\n\n    def get_announcements(self):\n        lines = []\n        lines.append(f\"Aider v{__version__}\")\n\n        # Model\n        main_model = self.main_model\n        weak_model = main_model.weak_model\n\n        if weak_model is not main_model:\n            prefix = \"Main model\"\n        else:\n            prefix = \"Model\"\n","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/Aider-AI/aider/blob/5dc9490bb35f9729ef2c95d00a19ccd30c26339c/aider/coders/base_coder.py#L183-L219","documentation":"Thrown by Coder.create() when the requested edit_format string does not match the edit_format attribute of any coder class registered in coders.__all__. The error message enumerates all valid formats collected from the registered coders. It is the top-level factory guard: no coder backend can be constructed for an unknown format name.","triggerScenarios":"Calling Coder.create(main_model, io, edit_format=...) (directly or via clone()/CLI --edit-format) with a string like 'diff', 'edit_block', or 'search-replace' that doesn't exactly equal a registered coder's edit_format (valid ones typically include 'whole', 'diff', 'diff-fenced', 'editor-diff', 'udiff', 'patch', 'ask'). Typos, case mismatches, and formats removed/renamed in newer aider versions all trigger it.","commonSituations":"Typo'd --edit-format CLI flag; scripts hard-coding an edit format that was renamed across aider versions; custom coder classes added to the package but missing the edit_format class attribute (they are silently skipped by the hasattr check); passing a model's name instead of the edit format.","solutions":["Read the error text: it prints the exact valid_formats list for your installed version; use one of those strings verbatim.","Check for typos/case: matching is exact string equality (e.g. 'editblock' vs the actual 'diff' naming used by your version).","Upgrade or align versions: if a script targets an older/newer aider, compare that version's coders/__init__.py export list to see which formats exist.","If you registered a custom coder, verify it is exported in coders.__all__ and has a non-None edit_format class attribute."],"exampleFix":"# before\ncoder = Coder.create(main_model=model, io=io, edit_format=\"editblock\")\n\n# after\ncoder = Coder.create(main_model=model, io=io, edit_format=\"diff\")  # use a value from the error's valid_formats list","handlingStrategy":"validation","validationCode":"from aider.coders import Coder\n\ndef valid_edit_formats():\n    from aider import coders\n    return {\n        str(c.edit_format)\n        for c in coders.__all__\n        if hasattr(c, \"edit_format\") and c.edit_format is not None\n    }\n\nfmt = \"diff\"\nassert fmt in valid_edit_formats(), f\"bad edit_format {fmt!r}; pick from {valid_edit_formats()}\"","typeGuard":"def is_valid_edit_format(fmt: str) -> bool:\n    from aider import coders\n    return any(\n        hasattr(c, \"edit_format\") and c.edit_format == fmt\n        for c in coders.__all__\n    )","tryCatchPattern":"from aider.coders import Coder\ntry:\n    coder = Coder.create(main_model=model, io=io, edit_format=fmt)\nexcept UnknownEditFormat as e:\n    # e.edit_format and e.valid_formats carry the details\n    print(f\"bad format {e.edit_format}; valid: {e.valid_formats}\")\n    raise SystemExit(2)","preventionTips":["Derive the accepted edit-format list from coders.__all__ at runtime instead of hard-coding strings that drift across aider versions.","Treat the error message's valid_formats list as the single source of truth when wiring CLI flags or config files.","Pin the aider version in requirements when scripts depend on a specific format naming."],"tags":["aider","edit-format","coder-factory","configuration"],"backgroundTag":null,"analyzedSha":"5dc9490bb35f9729ef2c95d00a19ccd30c26339c","analyzedAt":"2026-08-15T05:40:10.498Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}