{"record":{"id":"aedb6021ba3d6653","repo":"invoke-ai/InvokeAI","slug":"unknown-lora-lora-key-aedb60","errorCode":null,"errorMessage":"Unknown lora: {lora_key}!","messagePattern":"Unknown lora: (.+?)!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/z_image_lora_loader.py","lineNumber":61,"sourceCode":"    weight: float = InputField(default=0.75, description=FieldDescriptions.lora_weight)\n    transformer: TransformerField | None = InputField(\n        default=None,\n        description=FieldDescriptions.transformer,\n        input=Input.Connection,\n        title=\"Z-Image Transformer\",\n    )\n    qwen3_encoder: Qwen3EncoderField | None = InputField(\n        default=None,\n        title=\"Qwen3 Encoder\",\n        description=FieldDescriptions.qwen3_encoder,\n        input=Input.Connection,\n    )\n\n    def invoke(self, context: InvocationContext) -> ZImageLoRALoaderOutput:\n        lora_key = self.lora.key\n\n        if not context.models.exists(lora_key):\n            raise ValueError(f\"Unknown lora: {lora_key}!\")\n\n        # Check for existing LoRAs with the same key.\n        if self.transformer and any(lora.lora.key == lora_key for lora in self.transformer.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to transformer.')\n        if self.qwen3_encoder and any(lora.lora.key == lora_key for lora in self.qwen3_encoder.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to Qwen3 encoder.')\n\n        # Warn on variant mismatch between LoRA and transformer.\n        lora_config = context.models.get_config(lora_key)\n        lora_variant = getattr(lora_config, \"variant\", None)\n        if lora_variant and self.transformer is not None:\n            transformer_config = context.models.get_config(self.transformer.transformer.key)\n            transformer_variant = getattr(transformer_config, \"variant\", None)\n            if transformer_variant and lora_variant != transformer_variant:\n                context.logger.warning(\n                    f\"LoRA variant mismatch: LoRA '{lora_config.name}' is for {lora_variant.value} \"\n                    f\"but transformer is {transformer_variant.value}. This may cause unexpected results.\"\n                )","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/z_image_lora_loader.py#L43-L79","documentation":"ZImageLoRALoader.invoke verifies that the LoRA key supplied in self.lora.key exists in the model manager (context.models.exists). If it does not, the LoRA record is unknown/uninstalled and a ValueError is raised before any patching occurs. This prevents silently building a transformer/encoder output referencing a missing LoRA.","triggerScenarios":"Invoking the Z-Image LoRA loader with a ModelIdentifierField whose key is absent from the model-record store (deleted, never installed, or stale key from a copied graph or imported workflow).","commonSituations":"Deleting a LoRA from the Model Manager while a saved workflow still references it; importing shared workflow JSON with keys from another install; key format changed after a InvokeAI model-record migration; typos when constructing fields programmatically.","solutions":["Install the LoRA into InvokeAI (scan folder / add model) so its key exists in the model manager.","Re-select the LoRA in the node so the node stores a current, valid ModelIdentifierField key.","Repair/re-scan the models directory in the Model Manager if records are stale.","Update the workflow JSON to reference an existing LoRA key from this installation."],"exampleFix":"// before\nlora = ModelIdentifierField(key='8f3a-deleted-lora-key')\n// after\nlora = ModelIdentifierField(key='current-installed-z-image-lora-key')  # re-pick in UI","handlingStrategy":"validation","validationCode":"if not context.models.exists(loader.lora.key):\n    installed = [m.name for m in context.models.search_by_attr(attr='type', value=ModelType.LoRA)]\n    raise ValueError(f\"LoRA {loader.lora.key} not installed. Available: {installed}\")","typeGuard":null,"tryCatchPattern":"try:\n    out = z_image_lora_loader.invoke(context)\nexcept ValueError as e:\n    if str(e).startswith(\"Unknown lora:\"):\n        context.logger.error(f\"{e} - reinstall the LoRA or re-select it in the node.\")\n    else:\n        raise","preventionTips":["Re-select LoRAs in nodes after deleting/reinstalling models; keys change.","Don't hand-edit workflow JSON keys; pick models via the UI.","After migrations or restores, re-scan the models directory and fix broken references."],"tags":["lora","model-not-found","z-image","validation"],"backgroundTag":"model-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}