invoke-ai/InvokeAI · error · ValueError

Unknown lora: {lora_key}!

Error message

Unknown lora: {lora_key}!

What it means

The FLUX.2 dev LoRA loader looks up the supplied LoRA by its model key in the model manager. If context.models.exists(lora_key) is False, the LoRA is not registered/installed and invoke() raises ValueError with the unknown key.

Source

Thrown at invokeai/app/invocations/flux2_dev_lora_loader.py:92

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

    def invoke(self, context: InvocationContext) -> Flux2DevLoRALoaderOutput:
        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 variant-mismatched LoRAs regardless of which input they're wired to. A Klein
        # LoRA on a dev transformer/encoder is guaranteed to shape-error during denoise.
        _assert_dev_lora(context, lora_config)

        # Check for duplicate keys.
        if self.transformer and any(existing.lora.key == lora_key for existing in self.transformer.loras):
            raise ValueError(f'LoRA "{lora_key}" already applied to transformer.')
        if self.mistral_encoder and any(existing.lora.key == lora_key for existing in self.mistral_encoder.loras):
            raise ValueError(f'LoRA "{lora_key}" already applied to Mistral encoder.')

        output = Flux2DevLoRALoaderOutput()
        if self.transformer is not None:
            output.transformer = self.transformer.model_copy(deep=True)
            output.transformer.loras.append(LoRAField(lora=self.lora, weight=self.weight))
        if self.mistral_encoder is not None:

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Install the LoRA via Model Manager (add by URL or folder scan) so its key exists, then re-run
  2. Re-select the LoRA in the loader node so the field points at an installed model
  3. Run a model scan/import and verify the key with context.models.exists(key) before invoking

Example fix

# before
loader.lora = old_lora_field  # key no longer installed
# after
loader.lora = context.models.search_by_attrs(base='flux2', type='lora', name='my-lora')[0]  # installed model
Defensive patterns

Strategy: validation

Validate before calling

key = loader.lora.key
if not context.models.exists(key):
    raise ValueError(f'LoRA {key} not installed')

Try / catch

try:
    out = loader.invoke(context)
except ValueError as e:
    if str(e).startswith('Unknown lora:'):
        install_or_reselect_lora(loader)
        out = loader.invoke(context)
    else:
        raise

Prevention

When it happens

Trigger: Passing a lora ModelIdentifierField whose key is absent from the model record store — model uninstalled, key from another install, stale serialized graph, or wrong hash/key.

Common situations: Restoring a workflow shared by another user who has different models installed; model deleted from Model Manager while the graph still references it; copying graphs between machines.

Related errors


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