Aider-AI/aider · error · UnknownEditFormat
Unknown edit format {edit_format}. Valid formats are: {', '.
Error message
Unknown edit format {edit_format}. Valid formats are: {', '.join(valid_formats)} What it means
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.
Source
Thrown at aider/coders/base_coder.py:201
)
use_kwargs.update(update) # override to complete the switch
use_kwargs.update(kwargs) # override passed kwargs
kwargs = use_kwargs
from_coder.ok_to_warm_cache = False
for coder in coders.__all__:
if hasattr(coder, "edit_format") and coder.edit_format == edit_format:
res = coder(main_model, io, **kwargs)
res.original_kwargs = dict(kwargs)
return res
valid_formats = [
str(c.edit_format)
for c in coders.__all__
if hasattr(c, "edit_format") and c.edit_format is not None
]
raise UnknownEditFormat(edit_format, valid_formats)
def clone(self, **kwargs):
new_coder = Coder.create(from_coder=self, **kwargs)
return new_coder
def get_announcements(self):
lines = []
lines.append(f"Aider v{__version__}")
# Model
main_model = self.main_model
weak_model = main_model.weak_model
if weak_model is not main_model:
prefix = "Main model"
else:
prefix = "Model"
View on GitHub (pinned to 5dc9490bb3)
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.
Example fix
# before coder = Coder.create(main_model=model, io=io, edit_format="editblock") # after coder = Coder.create(main_model=model, io=io, edit_format="diff") # use a value from the error's valid_formats list
Defensive patterns
Strategy: validation
Validate before calling
from aider.coders import Coder
def valid_edit_formats():
from aider import coders
return {
str(c.edit_format)
for c in coders.__all__
if hasattr(c, "edit_format") and c.edit_format is not None
}
fmt = "diff"
assert fmt in valid_edit_formats(), f"bad edit_format {fmt!r}; pick from {valid_edit_formats()}" Type guard
def is_valid_edit_format(fmt: str) -> bool:
from aider import coders
return any(
hasattr(c, "edit_format") and c.edit_format == fmt
for c in coders.__all__
) Try / catch
from aider.coders import Coder
try:
coder = Coder.create(main_model=model, io=io, edit_format=fmt)
except UnknownEditFormat as e:
# e.edit_format and e.valid_formats carry the details
print(f"bad format {e.edit_format}; valid: {e.valid_formats}")
raise SystemExit(2) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid line_endings value: {line_endings}. Must be one of:
- Error loading model settings from {model_settings_fname}: {e
- Error loading model definition from {model_fname}: {e}
- No data found in LLM response!
- # {len(failed)} SEARCH/REPLACE {blocks} failed to match!\n
AI-assisted analysis of Aider-AI/aider@5dc9490bb3 (2026-08-15).
Data as JSON: /api/errors/9ffa543a78713258.
Report an issue: GitHub.