invoke-ai/InvokeAI · error · NotAMatchError

_class_name or architectures field is not a string: {config_

Error message

_class_name or architectures field is not a string: {config_class_name}

What it means

get_class_name_from_config_dict_or_raise reads the `_class_name` (single-path configs) or `architectures` (diffusers model_index.json style) field from a model config and returns it as the identifying class name string. If the parsed value is not a str (e.g. a list from `architectures`, a number, or None), the config cannot be matched to any config class, so a NotAMatchError is raised. This is part of InvokeAI's model-probing pipeline that classifies models on disk.

Source

Thrown at invokeai/backend/model_manager/configs/identification_utils.py:109

    """

    if not isinstance(config, dict):
        config = get_config_dict_or_raise(config)

    try:
        if "_class_name" in config:
            # This is a diffusers-style config
            config_class_name = config["_class_name"]
        elif "architectures" in config:
            # This is a transformers-style config
            config_class_name = config["architectures"][0]
        else:
            raise ValueError("missing _class_name or architectures field")
    except Exception as e:
        raise NotAMatchError(f"unable to determine class name from config file: {config}") from e

    if not isinstance(config_class_name, str):
        raise NotAMatchError(f"_class_name or architectures field is not a string: {config_class_name}")

    return config_class_name


def raise_for_class_name(config: Path | set[Path] | dict[str, Any], class_name: str | set[str]) -> None:
    """Get the class name from the config file and raise NotAMatch if it is not in the expected set.

    Args:
        config_path: The path to the config file, or a set of paths to try.
        class_name: The expected class name, or a set of expected class names.

    Raises:
        NotAMatch if the class name is not in the expected set.
    """

    class_name = {class_name} if isinstance(class_name, str) else class_name

    actual_class_name = get_class_name_from_config_dict_or_raise(config)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Inspect the model's config file (config.json or model_index.json) and make sure `_class_name` / `architectures` is a plain string value.
  2. If architectures is a list, take the single element that names the pipeline class and store it as a string.
  3. Re-export or re-download the model using a diffusers version that writes model_index.json in the expected shape.
  4. If the model genuinely doesn't belong to a supported format, accept the NotAMatch and register it with an explicit config instead of probing.

Example fix

// before (model_index.json)
{"architectures": ["FluxPipeline"], "_class_name": null}
// after
{"_class_name": "FluxPipeline"}
Defensive patterns

Strategy: validation

Validate before calling

import json, pathlib
cfg = json.loads(pathlib.Path(path, "model_index.json").read_text())
name = cfg.get("_class_name") or (cfg.get("architectures")[0] if isinstance(cfg.get("architectures"), list) and cfg["architectures"] else cfg.get("architectures"))
assert isinstance(name, str) and name, f"config class name is not a string: {name!r}"

Type guard

def is_str_class_name(v) -> bool:
    return isinstance(v, str) and len(v) > 0

Try / catch

from invokeai.backend.model_manager.configs.identification_utils import NotAMatchError
try:
    record = from_model_on_disk(mod)
except NotAMatchError as e:
    logger.warning("config class name invalid, skipping model: %s", e)

Prevention

When it happens

Trigger: Calling from_model_on_disk / raise_for_class_name / raise_if_config_doesnt_look_like_clip_vision on a model whose config dict has `_class_name` set to a non-string (or an `architectures` value that resolves to a non-string, such as the full architectures list instead of a single name).

Common situations: Hand-edited or generated model_index.json where architectures is a list rather than a string; custom config files with a numeric/None _class_name; third-party diffusers export formats that differ from what InvokeAI expects.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/a6c7b04cdaafb980. Report an issue: GitHub.