{"record":{"id":"584b814499d2385b","repo":"invoke-ai/InvokeAI","slug":"the-selected-saved-workflow-produced-an-unsupporte","errorCode":null,"errorMessage":"The selected saved workflow produced an unsupported number of workflow_return executions.","messagePattern":"The selected saved workflow produced an unsupported number of workflow_return executions\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/session_processor/workflow_call_runtime.py","lineNumber":150,"sourceCode":"        invocation = queue_item.session.execution_graph.nodes.get(waiting_frame.prepared_call_node_id)\n        if not isinstance(invocation, CallSavedWorkflowInvocation):\n            raise ValueError(\"Waiting workflow call frame does not point to a call_saved_workflow invocation.\")\n        return invocation\n\n    @staticmethod\n    def get_child_workflow_return_output(child_session: GraphExecutionState) -> WorkflowReturnOutput:\n        workflow_return_node_ids = [\n            node_id for node_id, node in child_session.graph.nodes.items() if node.get_type() == \"workflow_return\"\n        ]\n        if not workflow_return_node_ids:\n            raise ValueError(\"The selected saved workflow must contain exactly one workflow_return node.\")\n        if len(workflow_return_node_ids) > 1:\n            raise ValueError(\"The selected saved workflow must not contain more than one workflow_return node.\")\n\n        workflow_return_node_id = workflow_return_node_ids[0]\n        prepared_return_node_ids = child_session.source_prepared_mapping.get(workflow_return_node_id, set())\n        if len(prepared_return_node_ids) != 1:\n            raise ValueError(\n                \"The selected saved workflow produced an unsupported number of workflow_return executions.\"\n            )\n\n        prepared_return_node_id = next(iter(prepared_return_node_ids))\n        output = child_session.results.get(prepared_return_node_id)\n        if not isinstance(output, WorkflowReturnOutput):\n            raise ValueError(\"The selected saved workflow did not produce a valid workflow_return output.\")\n\n        return output\n\n    def resume_waiting_workflow_call(self, queue_item: SessionQueueItem) -> None:\n        invocation = self.get_waiting_workflow_call_invocation(queue_item)\n        child_session = queue_item.session.waiting_workflow_call_child_session\n        if child_session is None:\n            raise ValueError(\"Execution state is waiting on a workflow call but has no attached child session.\")\n        output = self.get_child_workflow_return_output(child_session)\n        queue_item.session.end_waiting_on_workflow_call(status=\"completed\")\n        queue_item.session.complete(invocation.id, output)","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/session_processor/workflow_call_runtime.py#L132-L168","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-enqueue the parent workflow so the child session is re-prepared from scratch","Check that the workflow_return node in the saved graph is a single, non-collected node with one invocation path","Update InvokeAI to the latest version; older versions had session-preparation bugs around batch/iteration expansion","If persisted, delete the stale child session state and retry"],"exampleFix":"// before: retrying against a stale child session\nresume_waiting_workflow_call(old_queue_item)\n// after: re-enqueue so a fresh child session is prepared\nnew_item = session_queue.enqueue_queue_item(fresh_session)","handlingStrategy":"validation","validationCode":"prepared = child_session.source_prepared_mapping.get(return_node_id, set())\nif len(prepared) != 1:\n    raise ValueError(f\"Expected exactly 1 prepared workflow_return execution, got {len(prepared)}.\")","typeGuard":"def has_single_prepared_return(session, return_node_id: str) -> bool:\n    return len(session.source_prepared_mapping.get(return_node_id, set())) == 1","tryCatchPattern":"try:\n    output = runtime.get_child_workflow_return_output(child_session)\nexcept ValueError:\n    # re-enqueue to get a freshly prepared child session\n    new_item = session_queue.enqueue_workflow_call_child(...)","preventionTips":["Keep InvokeAI updated; session-preparation bugs are fixed in newer releases","Avoid reusing persisted child sessions across app versions","Ensure the workflow_return node has a single, non-collected incoming path","Re-run the workflow rather than resuming suspect sessions"],"tags":["workflow","session","runtime"],"backgroundTag":"workflow-return-node-count-invalid","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}