{"record":{"id":"a6c7b04cdaafb980","repo":"invoke-ai/InvokeAI","slug":"class-name-or-architectures-field-is-not-a-string","errorCode":null,"errorMessage":"_class_name or architectures field is not a string: {config_class_name}","messagePattern":"_class_name or architectures field is not a string: (.+?)","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/identification_utils.py","lineNumber":109,"sourceCode":"    \"\"\"\n\n    if not isinstance(config, dict):\n        config = get_config_dict_or_raise(config)\n\n    try:\n        if \"_class_name\" in config:\n            # This is a diffusers-style config\n            config_class_name = config[\"_class_name\"]\n        elif \"architectures\" in config:\n            # This is a transformers-style config\n            config_class_name = config[\"architectures\"][0]\n        else:\n            raise ValueError(\"missing _class_name or architectures field\")\n    except Exception as e:\n        raise NotAMatchError(f\"unable to determine class name from config file: {config}\") from e\n\n    if not isinstance(config_class_name, str):\n        raise NotAMatchError(f\"_class_name or architectures field is not a string: {config_class_name}\")\n\n    return config_class_name\n\n\ndef raise_for_class_name(config: Path | set[Path] | dict[str, Any], class_name: str | set[str]) -> None:\n    \"\"\"Get the class name from the config file and raise NotAMatch if it is not in the expected set.\n\n    Args:\n        config_path: The path to the config file, or a set of paths to try.\n        class_name: The expected class name, or a set of expected class names.\n\n    Raises:\n        NotAMatch if the class name is not in the expected set.\n    \"\"\"\n\n    class_name = {class_name} if isinstance(class_name, str) else class_name\n\n    actual_class_name = get_class_name_from_config_dict_or_raise(config)","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/identification_utils.py#L91-L127","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Inspect the model's config file (config.json or model_index.json) and make sure `_class_name` / `architectures` is a plain string value.","If architectures is a list, take the single element that names the pipeline class and store it as a string.","Re-export or re-download the model using a diffusers version that writes model_index.json in the expected shape.","If the model genuinely doesn't belong to a supported format, accept the NotAMatch and register it with an explicit config instead of probing."],"exampleFix":"// before (model_index.json)\n{\"architectures\": [\"FluxPipeline\"], \"_class_name\": null}\n// after\n{\"_class_name\": \"FluxPipeline\"}","handlingStrategy":"validation","validationCode":"import json, pathlib\ncfg = json.loads(pathlib.Path(path, \"model_index.json\").read_text())\nname = cfg.get(\"_class_name\") or (cfg.get(\"architectures\")[0] if isinstance(cfg.get(\"architectures\"), list) and cfg[\"architectures\"] else cfg.get(\"architectures\"))\nassert isinstance(name, str) and name, f\"config class name is not a string: {name!r}\"","typeGuard":"def is_str_class_name(v) -> bool:\n    return isinstance(v, str) and len(v) > 0","tryCatchPattern":"from invokeai.backend.model_manager.configs.identification_utils import NotAMatchError\ntry:\n    record = from_model_on_disk(mod)\nexcept NotAMatchError as e:\n    logger.warning(\"config class name invalid, skipping model: %s\", e)","preventionTips":["Never hand-edit _class_name/architectures without keeping them as plain strings","After converting models to diffusers format, re-check model_index.json contents","Keep InvokeAI updated to track diffusers config format changes"],"tags":["model-config","validation","invokeai"],"backgroundTag":"invalid-config-field-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}