{"record":{"id":"54be67f792971dbe","repo":"invoke-ai/InvokeAI","slug":"unknown-model-key","errorCode":null,"errorMessage":"Unknown model: {key}","messagePattern":"Unknown model: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/flux_model_loader.py","lineNumber":91,"sourceCode":"        title=\"CLIP Embed\",\n        ui_model_type=ModelType.CLIPEmbed,\n    )\n\n    vae_model: ModelIdentifierField | None = InputField(\n        default=None,\n        description=FieldDescriptions.vae_model,\n        title=\"VAE\",\n        ui_model_base=BaseModelType.Flux,\n        ui_model_type=ModelType.VAE,\n    )\n\n    def invoke(self, context: InvocationContext) -> FluxModelLoaderOutput:\n        keys = [self.model.key] + [\n            m.key for m in (self.t5_encoder_model, self.clip_embed_model, self.vae_model) if m is not None\n        ]\n        for key in keys:\n            if not context.models.exists(key):\n                raise ValueError(f\"Unknown model: {key}\")\n\n        main_config = context.models.get_config(self.model)\n        self_contained = is_self_contained_sdnq_flux1_pipeline(main_config)\n\n        def resolve(selected: ModelIdentifierField | None) -> ModelIdentifierField | None:\n            \"\"\"Explicit selection wins; otherwise the main model supplies the part if it can.\"\"\"\n            if selected is not None:\n                return selected\n            return self.model if self_contained else None\n\n        t5_source = resolve(self.t5_encoder_model)\n        clip_source = resolve(self.clip_embed_model)\n        vae_source = resolve(self.vae_model)\n\n        missing = [\n            title\n            for title, source in ((\"T5 Encoder\", t5_source), (\"CLIP Embed\", clip_source), (\"VAE\", vae_source))\n            if source is None","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/flux_model_loader.py#L73-L109","documentation":"The FLUX model loader validates that the main transformer model and any selected companion models (T5 encoder, CLIP embed, VAE) exist in the model registry before loading. It raises ValueError('Unknown model: <key>') when context.models.exists(key) is false for any of them.","triggerScenarios":"invoke() builds keys from self.model plus optional t5_encoder_model/clip_embed_model/vae_model fields and any key is missing from the registry — deleted model, stale workflow reference, or invalid ModelIdentifierField.","commonSituations":"Model removed after the workflow was saved; workflow shared from another machine without the model installed; typo'd or hand-edited model key in a graph JSON.","solutions":["Re-select the FLUX model (and companions) in the workflow so fresh valid keys are stored","Install/scan the missing model via the Model Manager","Remove optional companion selections that no longer exist if the main model supplies them","Validate keys with context.models.exists() before running programmatically"],"exampleFix":"// before\nmodel=ModelIdentifierField(key='flux-dev-deleted')\n// after\nmodel=ModelIdentifierField(key='<re-selected FLUX model key>')","handlingStrategy":"validation","validationCode":"keys = [self.model.key] + [m.key for m in (t5, clip, vae) if m is not None]\nmissing = [k for k in keys if not context.models.exists(k)]\nif missing:\n    raise ValueError(f\"Models missing from registry: {missing}\")","typeGuard":"def all_models_exist(context, fields) -> bool:\n    return all(context.models.exists(m.key) for m in fields if m is not None)","tryCatchPattern":"try:\n    output = loader.invoke(context)\nexcept ValueError as e:\n    if str(e).startswith('Unknown model:'):\n        bad_key = str(e).rsplit(':', 1)[1].strip()\n        # re-select model with key bad_key\n    else:\n        raise","preventionTips":["Re-select models in workflows after model deletion or migration","Install all companion models when sharing workflows across machines","Validate model keys programmatically before dispatching graphs"],"tags":["missing-model","model-loader","flux","invokeai"],"backgroundTag":"unknown-model-key","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}