{"record":{"id":"c8417af6371ebed1","repo":"invoke-ai/InvokeAI","slug":"the-label-model-must-resolve-to-a-wan-main-model","errorCode":null,"errorMessage":"The {label} model must resolve to a Wan main model.","messagePattern":"The (.+?) model must resolve to a Wan main model\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/wan_model_loader.py","lineNumber":312,"sourceCode":"                \"No source for Wan T5 encoder. \"\n                \"Either set 'Wan T5 Encoder' to a standalone UMT5-XXL encoder, \"\n                \"or set 'Component Source' to a Diffusers Wan main model.\"\n            )\n\n        return WanModelLoaderOutput(\n            transformer=WanTransformerField(\n                transformer=transformer,\n                transformer_low_noise=transformer_low_noise,\n                boundary_ratio=boundary_ratio,\n            ),\n            wan_t5_encoder=WanT5EncoderField(tokenizer=tokenizer, text_encoder=text_encoder),\n            vae=VAEField(vae=vae),\n        )\n\n    @staticmethod\n    def _validate_main_config(config: object, label: str) -> None:\n        if getattr(config, \"base\", None) != BaseModelType.Wan or getattr(config, \"type\", None) != ModelType.Main:\n            raise ValueError(f\"The {label} model must resolve to a Wan main model.\")\n\n    @staticmethod\n    def _validate_component_source_format(context: InvocationContext, model: ModelIdentifierField) -> None:\n        source_config = context.models.get_config(model)\n        if source_config.base != BaseModelType.Wan or source_config.type != ModelType.Main:\n            raise ValueError(\"The Component Source model must resolve to a Wan main model.\")\n        if source_config.format != ModelFormat.Diffusers:\n            raise ValueError(\n                f\"The Component Source model must be in Diffusers format. \"\n                f\"The selected model '{source_config.name}' is in {source_config.format.value} format.\"\n            )\n\n    @staticmethod\n    def _validate_component_source_vae(\n        context: InvocationContext, model: ModelIdentifierField, main_variant: WanVariantType\n    ) -> None:\n        WanModelLoaderInvocation._validate_component_source_format(context, model)\n        source_config = context.models.get_config(model)","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/wan_model_loader.py#L294-L330","documentation":"_validate_main_config asserts that the resolved main model config has base BaseModelType.Wan and type ModelType.Main. If the selected model belongs to another base (SDXL, Flux, ...) or is not a Main model, invoke() fails with a message naming the field's label. It prevents silently feeding a foreign model into the Wan pipeline.","triggerScenarios":"invoke() with the 'model' (or override) field pointing at a model whose config.base != Wan or config.type != Main — e.g. a Wan VAE, a T5 encoder, or an SD1.5 main model passed where a Wan main model is required.","commonSituations":"Wiring the wrong model field into the loader in a workflow; selecting a Wan transformer/VAE submodel key instead of the main model; a model whose base metadata was mis-set during import.","solutions":["Select a Wan (base=Wan) Main model for the field named in the error label","Re-import or edit the model's base/type metadata if it was mis-registered","Use the main Wan model key, not a submodel key, in the invocation"],"exampleFix":"// before\nmodel=ModelIdentifierField(key='wan-vae-model', submodel_type=SubModelType.VAE)\n// after\nmodel=ModelIdentifierField(key='wan-main-model', submodel_type=SubModelType.Transformer)","handlingStrategy":"validation","validationCode":"cfg = context.models.get_config(field)\nif getattr(cfg, 'base', None) != BaseModelType.Wan or getattr(cfg, 'type', None) != ModelType.Main:\n    raise ValueError('Main model field must point at a Wan Main model')","typeGuard":"def is_wan_main(cfg) -> bool:\n    return getattr(cfg, 'base', None) == BaseModelType.Wan and getattr(cfg, 'type', None) == ModelType.Main","tryCatchPattern":"try:\n    output = invocation.invoke(context)\nexcept ValueError as e:\n    if 'must resolve to a Wan main model' in str(e):\n        field = select_wan_main_model()  # rebind the field named in the message","preventionTips":["Use the Wan + Main model-type filter when selecting the loader's model field","Reference the top-level main model key, not a submodel key","Verify model base metadata after importing"],"tags":["model-loader","wrong-model-type","wan","validation"],"backgroundTag":"wrong-model-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}