invoke-ai/InvokeAI · error · ValueError

The selected saved workflow produced an unsupported number o

Error message

The selected saved workflow produced an unsupported number of workflow_return executions.

What it means

After executing a child workflow, get_child_workflow_return_output maps the workflow_return node to its prepared node id and expects exactly one recorded execution. This ValueError fires when source_prepared_mapping contains zero or multiple prepared executions for the return node, i.e. the runtime cannot determine a single return output.

Source

Thrown at invokeai/app/services/session_processor/workflow_call_runtime.py:150

        invocation = queue_item.session.execution_graph.nodes.get(waiting_frame.prepared_call_node_id)
        if not isinstance(invocation, CallSavedWorkflowInvocation):
            raise ValueError("Waiting workflow call frame does not point to a call_saved_workflow invocation.")
        return invocation

    @staticmethod
    def get_child_workflow_return_output(child_session: GraphExecutionState) -> WorkflowReturnOutput:
        workflow_return_node_ids = [
            node_id for node_id, node in child_session.graph.nodes.items() if node.get_type() == "workflow_return"
        ]
        if not workflow_return_node_ids:
            raise ValueError("The selected saved workflow must contain exactly one workflow_return node.")
        if len(workflow_return_node_ids) > 1:
            raise ValueError("The selected saved workflow must not contain more than one workflow_return node.")

        workflow_return_node_id = workflow_return_node_ids[0]
        prepared_return_node_ids = child_session.source_prepared_mapping.get(workflow_return_node_id, set())
        if len(prepared_return_node_ids) != 1:
            raise ValueError(
                "The selected saved workflow produced an unsupported number of workflow_return executions."
            )

        prepared_return_node_id = next(iter(prepared_return_node_ids))
        output = child_session.results.get(prepared_return_node_id)
        if not isinstance(output, WorkflowReturnOutput):
            raise ValueError("The selected saved workflow did not produce a valid workflow_return output.")

        return output

    def resume_waiting_workflow_call(self, queue_item: SessionQueueItem) -> None:
        invocation = self.get_waiting_workflow_call_invocation(queue_item)
        child_session = queue_item.session.waiting_workflow_call_child_session
        if child_session is None:
            raise ValueError("Execution state is waiting on a workflow call but has no attached child session.")
        output = self.get_child_workflow_return_output(child_session)
        queue_item.session.end_waiting_on_workflow_call(status="completed")
        queue_item.session.complete(invocation.id, output)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Re-enqueue the parent workflow so the child session is re-prepared from scratch
  2. Check that the workflow_return node in the saved graph is a single, non-collected node with one invocation path
  3. Update InvokeAI to the latest version; older versions had session-preparation bugs around batch/iteration expansion
  4. If persisted, delete the stale child session state and retry

Example fix

// before: retrying against a stale child session
resume_waiting_workflow_call(old_queue_item)
// after: re-enqueue so a fresh child session is prepared
new_item = session_queue.enqueue_queue_item(fresh_session)
Defensive patterns

Strategy: validation

Validate before calling

prepared = child_session.source_prepared_mapping.get(return_node_id, set())
if len(prepared) != 1:
    raise ValueError(f"Expected exactly 1 prepared workflow_return execution, got {len(prepared)}.")

Type guard

def has_single_prepared_return(session, return_node_id: str) -> bool:
    return len(session.source_prepared_mapping.get(return_node_id, set())) == 1

Try / catch

try:
    output = runtime.get_child_workflow_return_output(child_session)
except ValueError:
    # re-enqueue to get a freshly prepared child session
    new_item = session_queue.enqueue_workflow_call_child(...)

Prevention

When it happens

Trigger: The child session's source_prepared_mapping has an entry for the workflow_return node whose set of prepared node ids is empty or has more than one element when the parent resumes via resume_waiting_workflow_call or _resume_parent_from_completed_child.

Common situations: Corrupted or partially-prepared child sessions, graphs whose return node is connected in a way that causes multiple prepared instances (e.g. inside an iterated subgraph), or internal runtime/version inconsistencies between session serialization formats.

Related errors


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