invoke-ai/InvokeAI · error · NotAMatchError

unable to load config file(s): {problems}

Error message

unable to load config file(s): {problems}

What it means

NotAMatchError raised by get_config_dict_or_raise when none of the candidate JSON config paths can be loaded: each path either does not exist or json.load failed, with per-path reasons collected in the 'problems' dict shown in the message. Many config classes call this during model identification, so it surfaces whenever a model directory's config.json is missing or malformed.

Source

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

    paths_to_check = config_path if isinstance(config_path, set) else {config_path}

    problems: dict[Path, str] = {}

    for p in paths_to_check:
        if not p.exists():
            problems[p] = "file does not exist"
            continue

        try:
            with open(p, "r") as file:
                config = json.load(file)

            return config
        except Exception as e:
            problems[p] = str(e)
            continue

    raise NotAMatchError(f"unable to load config file(s): {problems}")


def get_class_name_from_config_dict_or_raise(config: Path | set[Path] | dict[str, Any]) -> str:
    """Load the diffusers/transformers model config file and return the class name.

    Args:
        config_path: The path to the config file, or a set of paths to try.

    Returns:
        The class name from the config file.

    Raises:
        NotAMatch if the config file is missing or does not contain a valid class name.
    """

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

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Open the paths listed in the message: confirm config.json exists in the model root and re-download it if missing
  2. Validate the JSON (python -m json.tool config.json) and fix syntax errors, or re-download from the source repo
  3. Make sure you are pointing at the model directory (or the config.json file itself), not a weight file
  4. Check file permissions / disk errors if the file exists but cannot be opened

Example fix

// before
models/mymodel/{model.safetensors}  # config.json missing
// after
huggingface-cli download <repo> config.json --local-dir models/mymodel  # then: python -m json.tool config.json
Defensive patterns

Strategy: validation

Validate before calling

import json
from pathlib import Path

def loadable_config(model_dir: str | Path) -> dict | None:
    for name in ("config.json", "model_index.json"):
        p = Path(model_dir) / name
        if p.exists():
            try:
                return json.loads(p.read_text(encoding="utf-8"))
            except (json.JSONDecodeError, OSError):
                continue
    return None

Type guard

def has_valid_config_json(p: Path) -> bool:
    try:
        return isinstance(json.loads((p / "config.json").read_text()), dict)
    except (OSError, json.JSONDecodeError):
        return False

Try / catch

try:
    import_model(model_dir)
except NotAMatchError as e:
    if "unable to load config file(s)" in str(e):
        print("config.json missing or invalid — re-download it and run: python -m json.tool config.json")

Prevention

When it happens

Trigger: get_config_dict_or_raise(config_path) where the path set (e.g. {<dir>/config.json, <dir>/model_index.json}) contains no existing file, or the file exists but is not valid JSON (truncated download, BOM/encoding issue, empty file, wrong file passed directly).

Common situations: Model folder downloaded without config.json; interrupted HuggingFace download leaving a zero-byte or partial JSON; passing a safetensors file path instead of the config path; manually edited config.json with a syntax error.

Related errors


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