{"record":{"id":"6cda4b4a36e192b2","repo":"invoke-ai/InvokeAI","slug":"unknown-lora-lora-lora-key-6cda4b","errorCode":null,"errorMessage":"Unknown lora: {lora.lora.key}!","messagePattern":"Unknown lora: (.+?)!","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/krea2_lora_loader.py","lineNumber":144,"sourceCode":"        default=None,\n        title=\"Qwen3-VL Encoder\",\n        description=FieldDescriptions.qwen3_vl_encoder,\n        input=Input.Connection,\n    )\n\n    def invoke(self, context: InvocationContext) -> Krea2LoRALoaderOutput:\n        output = Krea2LoRALoaderOutput()\n        loras = self.loras if isinstance(self.loras, list) else [self.loras]\n        if self.transformer is not None:\n            output.transformer = self.transformer.model_copy(deep=True)\n        if self.qwen3_vl_encoder is not None:\n            output.qwen3_vl_encoder = self.qwen3_vl_encoder.model_copy(deep=True)\n\n        for lora in loras:\n            if lora is None:\n                continue\n            if not context.models.exists(lora.lora.key):\n                raise ValueError(f\"Unknown lora: {lora.lora.key}!\")\n            stored_config = context.models.get_config(lora.lora.key)\n            if (\n                lora.lora.base is not BaseModelType.Krea2\n                or stored_config.base is not BaseModelType.Krea2\n                or stored_config.type is not ModelType.LoRA\n            ):\n                raise ValueError(\n                    f\"LoRA '{lora.lora.key}' is for \"\n                    f\"{stored_config.base.value if stored_config.base else 'unknown'} models, \"\n                    \"not Krea-2 models. Ensure you are using a Krea-2 compatible LoRA.\"\n                )\n\n            transformer_lora = (\n                next((item for item in output.transformer.loras if item.lora.key == lora.lora.key), None)\n                if output.transformer is not None\n                else None\n            )\n            encoder_lora = (","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/krea2_lora_loader.py#L126-L162","documentation":"This is the bulk-validation path in invoke(): after copying transformer/encoder models, it iterates over all incoming lora entries and, for each, checks context.models.exists(lora.lora.key). Any entry whose model key is missing from the model manager raises ValueError('Unknown lora: ...'). It ensures every LoRA reference in the aggregated list points to a registered model before config lookup.","triggerScenarios":"invoke() on a Krea2 loader invocation whose loras list contains a LoRAField with a key absent from the model manager store (deleted model, stale workflow reference, cross-install copy).","commonSituations":"Shared workflows referencing models that were never installed on the target machine; model manager database rebuilt/reimported so keys changed; pruning unused models from disk without updating saved graphs.","solutions":["Open the workflow and re-select the missing LoRA in the loader node to bind a fresh valid key.","Re-install/re-import the referenced LoRA file so a model record with that key (or a new key) exists.","Compare the failing key against GET /api/v1/models to confirm it is absent, then update the graph accordingly.","Pre-validate all lora.lora.key values with context.models.exists() and skip or substitute missing entries before invoking."],"exampleFix":"// before\nloras = [LoRAField(lora=ModelIdentifierField(key=\"gone-123\"), weight=0.7)]\n// after: validate keys first\nloras = [l for l in loras if context.models.exists(l.lora.key)]  # or re-bind keys from model manager","handlingStrategy":"validation","validationCode":"missing = [l.lora.key for l in loras if l is not None and not context.models.exists(l.lora.key)]\nif missing:\n    raise LookupError(f\"Missing LoRA model records: {missing} - re-import or re-select before invoking\")","typeGuard":null,"tryCatchPattern":"try:\n    output = loader.invoke(context)\nexcept ValueError as e:\n    if str(e).startswith(\"Unknown lora:\"):\n        missing_key = str(e).split(\":\")[1].strip().rstrip(\"!\")\n        loras = substitute_lora(loras, missing_key, default_krea2_lora_key)\n        output = loader.model_copy(update={\"loras\": loras}).invoke(context)\n    else:\n        raise","preventionTips":["Validate every lora.lora.key against the models API before invoking a graph","Track model deletions and update saved workflows that referenced them","After database rebuilds/reimports, remap old keys to new ones in stored graphs","Fail fast in CI by dry-running workflows against a model inventory"],"tags":["model-manager","lora","missing-model","valueerror"],"backgroundTag":"unknown-model-key","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}