{"record":{"id":"36f6994620b26490","repo":"invoke-ai/InvokeAI","slug":"unknown-lora-lora-key-36f699","errorCode":null,"errorMessage":"Unknown lora: {lora_key}!","messagePattern":"Unknown lora: (.+?)!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/flux_lora_loader.py","lineNumber":68,"sourceCode":"    )\n    clip: CLIPField | None = InputField(\n        default=None,\n        title=\"CLIP\",\n        description=FieldDescriptions.clip,\n        input=Input.Connection,\n    )\n    t5_encoder: T5EncoderField | None = InputField(\n        default=None,\n        title=\"T5 Encoder\",\n        description=FieldDescriptions.t5_encoder,\n        input=Input.Connection,\n    )\n\n    def invoke(self, context: InvocationContext) -> FluxLoRALoaderOutput:\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.clip and any(lora.lora.key == lora_key for lora in self.clip.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to CLIP encoder.')\n        if self.t5_encoder and any(lora.lora.key == lora_key for lora in self.t5_encoder.loras):\n            raise ValueError(f'LoRA \"{lora_key}\" already applied to T5 encoder.')\n\n        output = FluxLoRALoaderOutput()\n\n        # Attach LoRA layers to the models.\n        if self.transformer is not None:\n            output.transformer = self.transformer.model_copy(deep=True)\n            output.transformer.loras.append(\n                LoRAField(\n                    lora=self.lora,\n                    weight=self.weight,","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/flux_lora_loader.py#L50-L86","documentation":"FluxLoRALoader.invoke looks up the LoRA by its model key via context.models.exists. If no model record with that key exists in the model manager, this ValueError is thrown, guarding the subsequent load and duplicate checks.","triggerScenarios":"The LoRA model was deleted or uninstalled after the workflow was saved; the key in the graph points to a different InvokeAI installation/database; a stale workflow JSON references a removed model.","commonSituations":"Sharing workflow JSONs between machines where LoRA keys (hash-based) differ; models removed via the Model Manager UI while workflows still reference them; switching model-manager databases.","solutions":["Re-select the LoRA in the LoRA loader node so the node picks up the current valid key.","Reinstall/re-import the LoRA file via the Model Manager so its key exists in the database.","If migrating workflows, replace the stale lora.key with the key from the destination installation's model list."],"exampleFix":"// before: workflow references deleted key\nlora_key = \"stale-key-from-old-install\"\n// after: rebind via UI or lookup\nlora_key = next(m.key for m in context.models.search_by_attrs(name=\"my_lora.safetensors\")).key","handlingStrategy":"try-catch","validationCode":"if not context.models.exists(self.lora.key):\n    raise ValueError(f\"LoRA {self.lora.key} missing from model manager; re-select it in the loader node\")","typeGuard":"def lora_exists(context, key: str) -> bool:\n    return context.models.exists(key)","tryCatchPattern":"try:\n    output = lora_loader.invoke(context)\nexcept ValueError as e:\n    if str(e).startswith(\"Unknown lora\"):\n        log.error(\"LoRA not found: %s - re-import the model or rebind the key\", lora_key)\n    else:\n        raise","preventionTips":["Re-select LoRAs in loader nodes after installing InvokeAI on a new machine.","Avoid deleting models referenced by saved workflows, or update the workflows afterwards.","Resolve model keys dynamically via the Model Manager API instead of hardcoding keys in scripts."],"tags":["python","valueerror","lora","model-not-found","flux"],"backgroundTag":"model-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}