{"record":{"id":"59427aa046ca2b64","repo":"invoke-ai/InvokeAI","slug":"an-expected-config-json-file-is-missing-from-this","errorCode":null,"errorMessage":"An expected config.json file is missing from this model.","messagePattern":"An expected config\\.json file is missing from this model\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/generic_diffusers.py","lineNumber":74,"sourceCode":"        result = None\n        if submodel_type:\n            try:\n                config = self._load_diffusers_config(model_path, config_name=\"model_index.json\")\n                module, class_name = config[submodel_type.value]\n                result = self._hf_definition_to_type(module=module, class_name=class_name)\n            except KeyError as e:\n                raise ValueError(f'The \"{submodel_type}\" submodel is not available for this model.') from e\n        else:\n            try:\n                config = self._load_diffusers_config(model_path, config_name=\"config.json\")\n                if class_name := config.get(\"_class_name\"):\n                    result = self._hf_definition_to_type(module=\"diffusers\", class_name=class_name)\n                elif class_name := config.get(\"architectures\"):\n                    result = self._hf_definition_to_type(module=\"transformers\", class_name=class_name[0])\n                else:\n                    raise RuntimeError(\"Unable to decipher Load Class based on given config.json\")\n            except KeyError as e:\n                raise ValueError(\"An expected config.json file is missing from this model.\") from e\n        assert result is not None\n        return result\n\n    # TO DO: Add exception handling\n    def _hf_definition_to_type(self, module: str, class_name: str) -> ModelMixin:  # fix with correct type\n        if module in [\n            \"diffusers\",\n            \"transformers\",\n            \"invokeai.backend.quantization.fast_quantized_transformers_model\",\n            \"invokeai.backend.quantization.fast_quantized_diffusion_model\",\n        ]:\n            res_type = sys.modules[module]\n        else:\n            res_type = sys.modules[\"diffusers\"].pipelines\n        result: ModelMixin = getattr(res_type, class_name)\n        return result\n\n    def _load_diffusers_config(self, model_path: Path, config_name: str = \"config.json\") -> dict[str, Any]:","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/generic_diffusers.py#L56-L92","documentation":"When get_hf_load_class resolves the diffusers/transformers class, it looks up the class name in the library's module maps. A KeyError means the referenced class or expected config entry does not exist; this except clause converts it to a ValueError stating that the model's config.json (or a key within it expected by the maps) is missing from the model. It signals the model directory is incomplete relative to what the loader expects.","triggerScenarios":"get_hf_load_class hits a KeyError while resolving class names from config.json — e.g. the config file itself is absent (lookup raised KeyError) or `_class_name`/`architectures` values point to entries missing from the loader's expected structure.","commonSituations":"Interrupted downloads leaving models without config.json; models converted with tools that drop metadata files; users pointing the loader at a checkpoint root that only contains weights.","solutions":["Check the model directory actually contains config.json and re-download it if missing.","Add a complete diffusers-style config.json (with `_class_name`) to the model directory.","If the class name in config is non-standard, rename it to the canonical diffusers/transformers class name.","Re-export the model using the official diffusers conversion script so all metadata files are produced."],"exampleFix":"// before: model dir contains only model.safetensors\n// after: ensure model dir contains config.json\n// model/config.json\n{ \"_class_name\": \"UNet2DConditionModel\", \"in_channels\": 4 }","handlingStrategy":"validation","validationCode":"cfg_path = model_path / \"config.json\"\nif not cfg_path.is_file():\n    raise FileNotFoundError(f\"Model directory missing config.json: {model_path}\")","typeGuard":"def config_json_present(model_path) -> bool:\n    import json\n    p = model_path / \"config.json\"\n    return p.is_file() and bool(json.loads(p.read_text()))","tryCatchPattern":"try:\n    cls = loader.get_hf_load_class(model_path)\nexcept ValueError as e:\n    if \"config.json\" in str(e):\n        re_download_model(model_path)  # restore missing metadata files\n    else:\n        raise","preventionTips":["Check for config.json before registering/loading any diffusers-format model.","Verify download integrity (all metadata files present) after fetching models.","Use resumable/download-managed fetches so interrupted downloads are detected."],"tags":["config","diffusers","missing-file"],"backgroundTag":"missing-config-file","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}