invoke-ai/InvokeAI · error · ValueError
Workflow return key '{key}' was not found.
Error message
Workflow return key '{key}' was not found. What it means
Workflow Return Get looks up self.key in the workflow's named return values dict. If the stripped key is non-empty but not present among the values the workflow returned, invoke() raises ValueError naming the missing key. This guards against typos and keys removed from the return node.
Source
Thrown at invokeai/app/invocations/workflow_return.py:138
)
class WorkflowReturnGetInvocation(BaseInvocation):
"""Extracts one named value from a callable workflow return."""
values: dict[str, Any] = InputField(
default={},
description="The named workflow return values.",
title="Values",
ui_type=UIType.Any,
input=Input.Connection,
)
key: str = InputField(default="", description="The return key to extract.", title="Key")
def invoke(self, context: InvocationContext) -> WorkflowReturnGetOutput:
key = self.key.strip()
if not key:
raise ValueError("Workflow return key must not be empty.")
if key not in self.values:
raise ValueError(f"Workflow return key '{key}' was not found.")
return WorkflowReturnGetOutput(value=self.values[key])
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Align the get node's 'key' with an existing key on the workflow-return node's values list
- Check exact spelling, case, and surrounding whitespace of both key fields
- Re-run the workflow and inspect which keys the return node actually emits
- Update stale workflow JSON so get nodes reference current return keys
Example fix
// before get = WorkflowReturnGetInvocation(values=return_values, key='outpt') // after get = WorkflowReturnGetInvocation(values=return_values, key='output')
Defensive patterns
Strategy: validation
Validate before calling
def key_exists(invocation, return_values):
k = invocation.key.strip()
return k in return_values
if not key_exists(invocation, return_values):
raise KeyError(f"'{invocation.key}' not in workflow return keys: {list(return_values)}") Try / catch
try:
output = invocation.invoke(context)
except ValueError as e:
if "was not found" in str(e):
log_missing_return_key(extract_key_from_message(str(e)))
else:
raise Prevention
- Rename return keys at the source and update all get nodes in the same edit
- Diff imported workflow JSON against current key names
- Use consistent casing; treat keys as case-sensitive
When it happens
Trigger: invoke() on a WorkflowReturnGet invocation where self.key (after .strip()) is not a key in the values dict produced by the workflow-return invocation, e.g. the return node no longer emits 'result' but the get node still requests it.
Common situations: Renaming or deleting a key on the workflow-return node while downstream get nodes still reference the old name; importing a workflow whose return keys changed between versions; a case/whitespace mismatch between the two key fields.
Related errors
- A saved workflow must be selected before executing call_save
- The selected saved workflow '${self.workflow_id}' could not
- Workflow return key must not be empty.
- Duplicate workflow return key '{key}'.
- Unsupported batch group id '{batch_group_id}' in called work
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/236ed48fee732a1a.
Report an issue: GitHub.