{"record":{"id":"17954ee3724e173c","repo":"invoke-ai/InvokeAI","slug":"unable-to-load-config-file-s-problems","errorCode":null,"errorMessage":"unable to load config file(s): {problems}","messagePattern":"unable to load config file\\(s\\): (.+?)","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/identification_utils.py","lineNumber":77,"sourceCode":"    paths_to_check = config_path if isinstance(config_path, set) else {config_path}\n\n    problems: dict[Path, str] = {}\n\n    for p in paths_to_check:\n        if not p.exists():\n            problems[p] = \"file does not exist\"\n            continue\n\n        try:\n            with open(p, \"r\") as file:\n                config = json.load(file)\n\n            return config\n        except Exception as e:\n            problems[p] = str(e)\n            continue\n\n    raise NotAMatchError(f\"unable to load config file(s): {problems}\")\n\n\ndef get_class_name_from_config_dict_or_raise(config: Path | set[Path] | dict[str, Any]) -> str:\n    \"\"\"Load the diffusers/transformers model config file and return the class name.\n\n    Args:\n        config_path: The path to the config file, or a set of paths to try.\n\n    Returns:\n        The class name from the config file.\n\n    Raises:\n        NotAMatch if the config file is missing or does not contain a valid class name.\n    \"\"\"\n\n    if not isinstance(config, dict):\n        config = get_config_dict_or_raise(config)\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/identification_utils.py#L59-L95","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Open the paths listed in the message: confirm config.json exists in the model root and re-download it if missing","Validate the JSON (python -m json.tool config.json) and fix syntax errors, or re-download from the source repo","Make sure you are pointing at the model directory (or the config.json file itself), not a weight file","Check file permissions / disk errors if the file exists but cannot be opened"],"exampleFix":"// before\nmodels/mymodel/{model.safetensors}  # config.json missing\n// after\nhuggingface-cli download <repo> config.json --local-dir models/mymodel  # then: python -m json.tool config.json","handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\ndef loadable_config(model_dir: str | Path) -> dict | None:\n    for name in (\"config.json\", \"model_index.json\"):\n        p = Path(model_dir) / name\n        if p.exists():\n            try:\n                return json.loads(p.read_text(encoding=\"utf-8\"))\n            except (json.JSONDecodeError, OSError):\n                continue\n    return None","typeGuard":"def has_valid_config_json(p: Path) -> bool:\n    try:\n        return isinstance(json.loads((p / \"config.json\").read_text()), dict)\n    except (OSError, json.JSONDecodeError):\n        return False","tryCatchPattern":"try:\n    import_model(model_dir)\nexcept NotAMatchError as e:\n    if \"unable to load config file(s)\" in str(e):\n        print(\"config.json missing or invalid — re-download it and run: python -m json.tool config.json\")","preventionTips":["Always download config.json together with weights (full-repo download)","Run python -m json.tool config.json after any manual edit","Check for zero-byte files after interrupted downloads","Point the importer at the model directory, not a weight file"],"tags":["config-file","json","model-import"],"backgroundTag":"missing-or-invalid-config-json","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}