{"record":{"id":"1b67b5c50ace2225","repo":"invoke-ai/InvokeAI","slug":"clip-embed-model-config-dict-must-include-a-varia","errorCode":null,"errorMessage":"CLIP Embed model config dict must include a 'variant' field","messagePattern":"CLIP Embed model config dict must include a 'variant' field","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/base.py","lineNumber":200,"sourceCode":"                    base_ = str(base_.value)\n                elif not isinstance(base_, str):\n                    raise ValueError(\"Model config dict 'base' field must be a string or Enum\")\n                tag_strings.append(base_)\n\n            # Special case: CLIP Embed models also need the variant to distinguish them.\n            if (\n                type_ == ModelType.CLIPEmbed.value\n                and format_ == ModelFormat.Diffusers.value\n                and base_ == BaseModelType.Any.value\n            ):\n                if variant_ := v.get(\"variant\"):\n                    if isinstance(variant_, Enum):\n                        variant_ = variant_.value\n                    elif not isinstance(variant_, str):\n                        raise ValueError(\"Model config dict 'variant' field must be a string or Enum\")\n                    tag_strings.append(variant_)\n                else:\n                    raise ValueError(\"CLIP Embed model config dict must include a 'variant' field\")\n\n            return \".\".join(tag_strings)\n        else:\n            raise ValueError(\n                \"Model config discriminator value must be computed from a dict or ModelConfigBase instance\"\n            )\n\n    @classmethod\n    @abstractmethod\n    def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:\n        \"\"\"Given the model on disk and any override fields, attempt to construct an instance of this config class.\n\n        This method serves to identify whether the model on disk matches this config class, and if so, to extract any\n        additional metadata needed to instantiate the config.\n\n        Implementations should raise a NotAMatchError if the model does not match this config class.\"\"\"\n        raise NotImplementedError(f\"from_model_on_disk not implemented for {cls.__name__}\")\n","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/base.py#L182-L218","documentation":"CLIP Embed model configs additionally need 'variant' to distinguish model variants in the discriminator tag; when the field is absent entirely, this ValueError is raised by get_model_discriminator_value.","triggerScenarios":"Instantiating a config dict with type='clip_embed', format='diffusers', base='any' but no 'variant' key at all.","commonSituations":"Importing configs from older InvokeAI versions or third-party tools that omit variant; hand-written dicts missing the field; partial deserialization dropping None/missing keys.","solutions":["Add the variant field, e.g. {'variant': CLIPVisionModelVariant.LARGE.value} (typically 'large' or 'huge').","Inspect the model's config.json in its diffusers folder to determine the correct variant.","If the model is not actually CLIP Embed, correct the 'type'/'format' fields so the special case doesn't apply."],"exampleFix":"// before\n{'type': 'clip_embed', 'format': 'diffusers', 'base': 'any'}\n// after\n{'type': 'clip_embed', 'format': 'diffusers', 'base': 'any', 'variant': 'large'}","handlingStrategy":"validation","validationCode":"def ensure_clip_embed_variant(cfg: dict) -> dict:\n    if cfg.get('type') == 'clip_embed' and cfg.get('format') == 'diffusers' and not cfg.get('variant'):\n        cfg['variant'] = 'large'  # or read from the model's config.json\n    return cfg","typeGuard":"def has_required_clip_embed_fields(cfg: dict) -> bool:\n    return bool(cfg.get('variant')) if (\n        cfg.get('type') == 'clip_embed' and cfg.get('format') == 'diffusers'\n    ) else True","tryCatchPattern":"try:\n    config = AnyModelConfig(**cfg)\nexcept ValueError as e:\n    if \"must include a 'variant' field\" in str(e):\n        cfg['variant'] = 'large'\n        config = AnyModelConfig(**cfg)\n    else:\n        raise","preventionTips":["Inspect the model's diffusers config.json to determine variant before registering.","Require variant in any importer that emits clip_embed configs.","Keep configs complete via model_dump() round-trips rather than hand-assembled dicts."],"tags":["invokeai","pydantic","discriminator","missing-field","clip-embed"],"backgroundTag":"missing-required-field","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}