invoke-ai/InvokeAI · error · ValueError

Unknown lora: {lora_key}!

Error message

Unknown lora: {lora_key}!

What it means

WanLoRALoaderInvocation.invoke raises this ValueError when the LoRA model identified by self.lora.key does not exist in the model manager (context.models.exists returns False). It is a guard ensuring the referenced LoRA record is present before any config lookup or loading. The graph node cannot proceed without a valid, installed LoRA model.

Source

Thrown at invokeai/app/invocations/wan_lora_loader.py:179

    target: WanLoRATarget = InputField(
        default="auto",
        description="Which expert(s) to apply this LoRA to. 'auto' uses the LoRA's "
        "recorded expert tag (or both if untagged); 'both'/'high'/'low' override it. "
        "On the single-transformer TI2V-5B, which has no low-noise expert, 'low' is "
        "applied to the transformer instead of being discarded.",
    )
    transformer: WanTransformerField | None = InputField(
        default=None,
        description=FieldDescriptions.transformer,
        input=Input.Connection,
        title="Wan Transformer",
    )

    def invoke(self, context: InvocationContext) -> WanLoRALoaderOutput:
        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(self.lora)
        _assert_is_wan_lora(lora_config, lora_key)

        output = WanLoRALoaderOutput()
        if self.transformer is None:
            return output

        main_config = context.models.get_config(self.transformer.transformer)
        _assert_lora_variant_matches_main(lora_config, main_config, lora_key)

        lora_expert = getattr(lora_config, "expert", None)
        to_primary, to_low_noise = _resolve_target(self.target, lora_expert)
        to_primary, to_low_noise = _correct_inert_low_routing(context, main_config, lora_key, to_primary, to_low_noise)

        # Reject duplicates on whichever list(s) we're about to append to.
        if to_primary and any(item.lora.key == lora_key for item in self.transformer.loras):
            raise ValueError(f'LoRA "{lora_key}" already applied to primary transformer list.')

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Install/import the referenced LoRA model in InvokeAI's model manager (Wan base, LoRA type) so the key resolves.
  2. Open the workflow and re-select the LoRA in the 'Apply LoRA - Wan 2.2' node to refresh the ModelIdentifierField key.
  3. If migrating workflows, rebind model fields to models present on the target instance.

Example fix

// before: workflow references a deleted lora key
self.lora.key  # "88f3..." no longer exists -> ValueError: Unknown lora!
// after: re-select the LoRA in the node UI, or verify first
if not context.models.exists(lora_key):
    # install the LoRA or pick a different one in the node
    ...
Defensive patterns

Strategy: validation

Validate before calling

# before wiring/running the loader
if not context.models.exists(lora_key):
    raise LookupError(f"LoRA {lora_key} not installed; install it or re-select in the node")

Type guard

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

Try / catch

try:
    out = wan_lora_loader.invoke(context)
except ValueError as e:
    if "Unknown lora" in str(e):
        install_model(lora_key) or rebind_lora_field(node)
    else:
        raise

Prevention

When it happens

Trigger: Calling the 'wan_lora_loader' invocation with a lora ModelIdentifierField whose key is not in the model manager: the model was uninstalled/deleted after the workflow was saved, the workflow was imported with keys from another InvokeAI instance, or a stale/edited key was injected.

Common situations: Restoring a workflow JSON on a fresh install without the LoRA; deleting the LoRA from the model manager while a saved workflow still references it; hand-editing or migrating graph state with stale model keys; syncing workflows across machines with different model installs.

Related errors


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