invoke-ai/InvokeAI · error · Exception

Unknown lora: {lora.lora.key}!

Error message

Unknown lora: {lora.lora.key}!

What it means

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.

Source

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

    def invoke(self, context: InvocationContext) -> Flux2KleinLoRALoaderOutput:
        output = Flux2KleinLoRALoaderOutput()
        loras = self.loras if isinstance(self.loras, list) else [self.loras]
        added_loras: list[str] = []

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

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

        for lora in loras:
            if lora is None:
                continue
            if lora.lora.key in added_loras:
                continue

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

            if lora.lora.base is not BaseModelType.Flux2:
                raise ValueError(
                    f"LoRA '{lora.lora.key}' is for {lora.lora.base.value if lora.lora.base else 'unknown'} models, "
                    "not FLUX.2 Klein models. Ensure you are using a FLUX.2 compatible LoRA."
                )

            lora_config = context.models.get_config(lora.lora.key)
            # Reject cross-family (dev) LoRAs, matching the single-LoRA loader above.
            _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(

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Re-install or re-import the missing LoRA model so its key exists in the model manager
  2. Open the workflow and re-select the LoRA to refresh its key to the current model record
  3. Remove stale LoRA entries from the workflow before running
  4. Catch the exception and surface which key is missing so the user can fix the model list

Example fix

// before
context.models.exists(lora.lora.key)  # False -> Exception
// after
if not context.models.exists(lora.lora.key):
    lora.lora.key = reselect_lora_key(lora.lora.name)  # refresh to a valid installed model
    assert context.models.exists(lora.lora.key)
Defensive patterns

Strategy: validation

Validate before calling

missing = [l.lora.key for l in loader.loras
           if not context.models.exists(l.lora.key)]
if missing:
    raise ValueError(f"LoRA models not installed: {missing}")

Type guard

def lora_installed(key: str, context) -> bool:
    return context.models.exists(key)

Try / catch

try:
    output = loader.invoke(context)
except Exception as e:
    if str(e).startswith('Unknown lora:'):
        key = str(e).split(':')[1].strip().rstrip('!')
        refresh_or_remove_lora(key)
    else:
        raise

Prevention

When it happens

Trigger: 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().

Common situations: 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.

Related errors


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