invoke-ai/InvokeAI · error · ValueError

Unknown lora: {lora_key}!

Error message

Unknown lora: {lora_key}!

What it means

The FLUX.2 Klein LoRA loader raises this ValueError when the key of the LoRA model reference in the lora input does not exist in the model manager. context.models.exists(lora_key) returns False, meaning the model record is missing - typically deleted, never imported, or a stale reference from a moved/renamed model.

Source

Thrown at invokeai/app/invocations/flux2_klein_lora_loader.py:85

    weight: float = InputField(default=0.75, description=FieldDescriptions.lora_weight)
    transformer: TransformerField | None = InputField(
        default=None,
        description=FieldDescriptions.transformer,
        input=Input.Connection,
        title="Transformer",
    )
    qwen3_encoder: Qwen3EncoderField | None = InputField(
        default=None,
        title="Qwen3 Encoder",
        description=FieldDescriptions.qwen3_encoder,
        input=Input.Connection,
    )

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

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

        lora_config = context.models.get_config(lora_key)
        # Reject cross-family (dev) LoRAs regardless of which input they're wired to.
        _assert_not_dev_lora(context, lora_config)

        # Warn if LoRA variant doesn't match transformer variant (intra-Klein 4B/9B).
        lora_variant = getattr(lora_config, "variant", None)
        if lora_variant and self.transformer is not None:
            transformer_config = context.models.get_config(self.transformer.transformer.key)
            transformer_variant = getattr(transformer_config, "variant", None)
            if transformer_variant and lora_variant != transformer_variant:
                context.logger.warning(
                    f"LoRA variant mismatch: LoRA '{lora_config.name}' is for {lora_variant.value} "
                    f"but transformer is {transformer_variant.value}. This may cause shape errors."
                )

        # Check for existing LoRAs with the same key.
        if self.transformer and any(lora.lora.key == lora_key for lora in self.transformer.loras):

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Install/import the referenced LoRA into InvokeAI's model manager so its key exists.
  2. Re-select the LoRA in the Klein LoRA loader node to refresh the stale model reference.
  3. Re-open and re-save the workflow after re-selecting, so the embedded key matches the local model database.

Example fix

// before
loader = Flux2KleinLoRALoader(lora=stale_lora_ref)  // key not in model manager
// after
loader = Flux2KleinLoRALoader(lora=context.models.get_config_by_name('my_klein_lora').key)
Defensive patterns

Strategy: validation

Validate before calling

lora_key = lora_ref.key
if not context.models.exists(lora_key):
    raise ValueError(f"LoRA {lora_key} is not installed; re-select it in the Model Manager")

Type guard

def lora_is_installed(context, lora_ref) -> bool:
    return context.models.exists(lora_ref.key)

Try / catch

try:
    output = klein_lora_loader.invoke(context)
except ValueError as e:
    if str(e).startswith("Unknown lora:"):
        lora_ref = reselect_lora_by_name(context, lora_ref.name)
        klein_lora_loader.lora = lora_ref
        output = klein_lora_loader.invoke(context)
    else:
        raise

Prevention

When it happens

Trigger: invoke() reads lora_key = self.lora.key and context.models.exists(lora_key) is False before any config lookup.

Common situations: A workflow saved on another machine references a LoRA not installed locally; the LoRA was deleted or re-imported under a new key; or the model database was reset while the workflow kept the old reference.

Related errors


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