invoke-ai/InvokeAI · error · ValidationError
No model config class found for type={target_type!r}
Error message
No model config class found for type={target_type!r} What it means
_construct_config_for_type tries candidate pydantic config classes for a given model record type; if none exists for target_type and no candidate produced a ValidationError, it synthesizes a ValidationError stating no config class was found. This surfaces through update_model when a model record has an unknown/unregistered model type.
Source
Thrown at invokeai/app/services/model_records/model_records_sql.py:86
def _construct_config_for_type(fields: dict, target_type: ModelType) -> AnyModelConfig:
"""Try every config class whose `type` default matches `target_type` and return the first that validates.
Used when changing a model's type via the update endpoint: the existing record's `format`/`variant`
fields belong to the old class and may not have a discriminator match in the new type space, so we
fall back to constructing each candidate class directly with whatever fields it accepts.
"""
last_error: Exception | None = None
for candidate_class in Config_Base.CONFIG_CLASSES:
type_field = candidate_class.model_fields.get("type")
if type_field is None or type_field.default != target_type:
continue
try:
return candidate_class(**fields) # type: ignore[return-value]
except ValidationError as e:
last_error = e
if last_error is not None:
raise last_error
raise ValidationError.from_exception_data(
f"No model config class found for type={target_type!r}",
line_errors=[],
)
class ModelRecordServiceSQL(ModelRecordServiceBase):
"""Implementation of the ModelConfigStore ABC using a SQL database."""
def __init__(self, db: SqliteDatabase, logger: logging.Logger):
"""
Initialize a new object from preexisting sqlite3 connection and threading lock objects.
:param db: Sqlite connection object
"""
super().__init__()
self._db = db
self._logger = logger
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Check the type field of the offending model row and correct it to a valid model type.
- Update InvokeAI so the running code recognizes the record's type (version mismatch).
- Delete the invalid record via del_model and re-add the model.
- Restore the models DB from a backup or re-scan models from disk.
Example fix
# before
# models table row: {"type": "main_v3_experimental", ...}
# after
# correct the row to a known type
# {"type": "main", ...} (or upgrade InvokeAI to a version that knows the type) Defensive patterns
Strategy: try-catch
Validate before calling
KNOWN_TYPES = {'main','vae','controlnet','embedding','lora','t2i_adapter','textual_inversion','ip_adapter','clip_vision','sig_lora','unknown'}
assert record.get('type') in KNOWN_TYPES, f"Unknown model type: {record.get('type')!r}" Type guard
def has_known_type(rec: dict) -> bool:
return rec.get('type') in {'main','vae','controlnet','embedding','lora','t2i_adapter','ip_adapter','clip_vision','sig_lora'} Try / catch
try:
records.update_model(key, changes)
except ValidationError as e:
if 'No model config class found' in str(e):
log.error('Record %s has an unrecognized type; skipping or re-adding', key)
records.del_model(key)
else:
raise Prevention
- Keep InvokeAI versions consistent with the database you operate on
- Never hand-edit the models DB
- Re-add models with unrecognized types from source files
When it happens
Trigger: Updating a model record (update_model) whose stored type value is not one of the known model types (e.g. a corrupted DB row, a type from a newer/older InvokeAI version, or hand-edited database).
Common situations: Database written by a different InvokeAI version where the type enum changed; manual SQL edits introducing a bad type string; plugin/custom model types not registered in the running process.
Related errors
- Selected model provider '{model_config.provider_id}' does no
- Model '{lora_key}' is not a Wan LoRA (resolved to type={geta
- _class_name or architectures field is not a string: {config_
- No external provider config fields provided
- str(e)
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/9187f48dfa36fe19.
Report an issue: GitHub.