invoke-ai/InvokeAI · error · ValueError

Unknown lora: {lora_key}!

Error message

Unknown lora: {lora_key}!

What it means

Krea2LoRALoaderInvocation.invoke() resolves the LoRA model by its key via context.models.exists(). If no model record exists in the model manager for that key, it raises ValueError('Unknown lora: ...'). This guards against loading a LoRA whose model record has been deleted or never registered before attempting to fetch its config.

Source

Thrown at invokeai/app/invocations/krea2_lora_loader.py:61

    weight: float = InputField(default=0.75, description=FieldDescriptions.lora_weight)
    transformer: TransformerField | None = InputField(
        default=None,
        description=FieldDescriptions.transformer,
        input=Input.Connection,
        title="Krea-2 Transformer",
    )
    qwen3_vl_encoder: Qwen3VLEncoderField | None = InputField(
        default=None,
        title="Qwen3-VL Encoder",
        description=FieldDescriptions.qwen3_vl_encoder,
        input=Input.Connection,
    )

    def invoke(self, context: InvocationContext) -> Krea2LoRALoaderOutput:
        lora_key = self.lora.key

        if not context.models.exists(lora_key):
            raise ValueError(f"Unknown lora: {lora_key}!")

        stored_config = context.models.get_config(lora_key)
        if (
            self.lora.base is not BaseModelType.Krea2
            or stored_config.base is not BaseModelType.Krea2
            or stored_config.type is not ModelType.LoRA
        ):
            raise ValueError(
                f"LoRA '{lora_key}' is for {stored_config.base.value if stored_config.base else 'unknown'} models, "
                "not Krea-2 models. Ensure you are using a Krea-2 compatible LoRA."
            )

        output = Krea2LoRALoaderOutput()

        if self.transformer is not None:
            output.transformer = self.transformer.model_copy(deep=True)
        if self.qwen3_vl_encoder is not None:
            output.qwen3_vl_encoder = self.qwen3_vl_encoder.model_copy(deep=True)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Re-select the LoRA in the LoRA loader node so the workflow stores the current valid model key.
  2. Verify the model exists in the Model Manager (or via GET /api/v1/models) and re-import the LoRA file if missing.
  3. Rebuild/convert the model manager database (invokeai-db) if keys changed after an upgrade.
  4. Wrap model loading in a catch for ValueError and fall back to a default Krea2-compatible LoRA.

Example fix

// before (stale key from old workflow)
{ "type": "krea2_lora_loader", "lora": { "key": "8f3c...old" } }
// after (key refreshed from model manager)
{ "type": "krea2_lora_loader", "lora": { "key": "a91d...current" } }
Defensive patterns

Strategy: validation

Validate before calling

lora_key = loader.lora.key
if not context.models.exists(lora_key):
    raise LookupError(f"LoRA {lora_key} not in model manager - re-select or re-import it before invoking")

Try / catch

try:
    output = loader.invoke(context)
except ValueError as e:
    if str(e).startswith("Unknown lora:"):
        output = fallback_loader_with_default_lora().invoke(context)
    else:
        raise

Prevention

When it happens

Trigger: Calling invoke() of Krea2LoRALoaderInvocation where self.lora.key does not exist in the model manager store, i.e. context.models.exists(lora_key) returns False.

Common situations: Referencing a LoRA from a saved workflow after the model was deleted or re-imported (changing its hash/key); copy-pasting workflow JSON between installs; stale model manager DB after upgrading InvokeAI; a LoRA installed after the graph was built.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/700532df8254f7f0. Report an issue: GitHub.