{"record":{"id":"2d4b0a7f93b8c4a2","repo":"invoke-ai/InvokeAI","slug":"unknown-lora-lora-lora-key-2d4b0a","errorCode":null,"errorMessage":"Unknown lora: {lora.lora.key}!","messagePattern":"Unknown lora: (.+?)!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/flux2_klein_lora_loader.py","lineNumber":181,"sourceCode":"    def invoke(self, context: InvocationContext) -> Flux2KleinLoRALoaderOutput:\n        output = Flux2KleinLoRALoaderOutput()\n        loras = self.loras if isinstance(self.loras, list) else [self.loras]\n        added_loras: list[str] = []\n\n        if self.transformer is not None:\n            output.transformer = self.transformer.model_copy(deep=True)\n\n        if self.qwen3_encoder is not None:\n            output.qwen3_encoder = self.qwen3_encoder.model_copy(deep=True)\n\n        for lora in loras:\n            if lora is None:\n                continue\n            if lora.lora.key in added_loras:\n                continue\n\n            if not context.models.exists(lora.lora.key):\n                raise Exception(f\"Unknown lora: {lora.lora.key}!\")\n\n            if lora.lora.base is not BaseModelType.Flux2:\n                raise ValueError(\n                    f\"LoRA '{lora.lora.key}' is for {lora.lora.base.value if lora.lora.base else 'unknown'} models, \"\n                    \"not FLUX.2 Klein models. Ensure you are using a FLUX.2 compatible LoRA.\"\n                )\n\n            lora_config = context.models.get_config(lora.lora.key)\n            # Reject cross-family (dev) LoRAs, matching the single-LoRA loader above.\n            _assert_not_dev_lora(context, lora_config)\n\n            # Warn if LoRA variant doesn't match transformer variant (intra-Klein 4B/9B).\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(","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/flux2_klein_lora_loader.py#L163-L199","documentation":"invoke() raised a generic Exception because context.models.exists(lora.lora.key) returned False — the LoRA model-key referenced by the loader input is not present in the model manager. The library throws it to stop execution before trying to fetch a model config that does not exist.","triggerScenarios":"A LoRA entry in the loader input carries a key that was removed from the models directory, was never installed, or whose config record was deleted, so context.models.exists() is False during invoke().","commonSituations":"Models folder cleaned up or moved after the workflow was saved; model renamed/re-imported producing a new hash key; stale workflow JSON referencing deleted models; sync between machines losing the model.","solutions":["Re-install or re-import the missing LoRA model so its key exists in the model manager","Open the workflow and re-select the LoRA to refresh its key to the current model record","Remove stale LoRA entries from the workflow before running","Catch the exception and surface which key is missing so the user can fix the model list"],"exampleFix":"// before\ncontext.models.exists(lora.lora.key)  # False -> Exception\n// after\nif not context.models.exists(lora.lora.key):\n    lora.lora.key = reselect_lora_key(lora.lora.name)  # refresh to a valid installed model\n    assert context.models.exists(lora.lora.key)","handlingStrategy":"validation","validationCode":"missing = [l.lora.key for l in loader.loras\n           if not context.models.exists(l.lora.key)]\nif missing:\n    raise ValueError(f\"LoRA models not installed: {missing}\")","typeGuard":"def lora_installed(key: str, context) -> bool:\n    return context.models.exists(key)","tryCatchPattern":"try:\n    output = loader.invoke(context)\nexcept Exception as e:\n    if str(e).startswith('Unknown lora:'):\n        key = str(e).split(':')[1].strip().rstrip('!')\n        refresh_or_remove_lora(key)\n    else:\n        raise","preventionTips":["Re-open workflows after model imports/removals to refresh keys","Run context.models.exists() over all LoRA references before executing the graph","Avoid hand-editing model keys in workflow JSON"],"tags":["model-not-found","lora","invokeai"],"backgroundTag":"model-key-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}