{"record":{"id":"775c793790848185","repo":"n8n-io/n8n","slug":"there-was-an-error-the-workflow-did-not-return-a-775c79","errorCode":null,"errorMessage":"There was an error: \"The workflow did not return a response\"","messagePattern":"There was an error: \"The workflow did not return a response\"","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.ts","lineNumber":285,"sourceCode":"\t\t\t\t\texecutionId: workflowProxy.$execution.id,\n\t\t\t\t\tworkflowId: workflowProxy.$workflow.id,\n\t\t\t\t},\n\t\t\t\treturnLastRunOnly: true, // The tool's answer is the sub-workflow's final-run output, not its internal multi-run computation.\n\t\t\t});\n\t\t\t// Set sub-workflow execution id so it can be used in other places\n\t\t\tthis.subExecutionId = receivedData.executionId;\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(context.getNode(), error as Error);\n\t\t}\n\n\t\tlet response: IDataObject | INodeExecutionData[] | undefined;\n\t\tif (this.returnAllItems) {\n\t\t\tresponse = receivedData?.data?.[0]?.length ? receivedData.data[0] : undefined;\n\t\t} else {\n\t\t\tresponse = receivedData?.data?.[0]?.[0]?.json;\n\t\t}\n\t\tif (response === undefined) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tcontext.getNode(),\n\t\t\t\t'There was an error: \"The workflow did not return a response\"',\n\t\t\t);\n\t\t}\n\n\t\treturn { response, subExecutionId: receivedData.executionId };\n\t}\n\n\t/**\n\t * Gets the sub-workflow info based on the source and executes it.\n\t * This function will be called as part of the tool execution (from the toolHandler)\n\t */\n\tprivate async runFunction(\n\t\tcontext: ISupplyDataFunctions | IExecuteFunctions,\n\t\tquery: string | IDataObject,\n\t\titemIndex: number,\n\t\trunManager?: CallbackManagerForToolRun,\n\t): Promise<IDataObject | INodeExecutionData[]> {","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.ts#L267-L303","documentation":"Thrown by WorkflowToolService.executeSubWorkflow (v2) when, after a successful execution, the expected response slot is undefined. With returnAllItems=true it fires when receivedData.data[0] has no items; otherwise when receivedData.data[0][0].json is undefined. The tool needs a concrete payload to return.","triggerScenarios":"Sub-workflow runs but its terminal main-output node emits zero items; the answer lives on a non-zero run or output; returnLastRunOnly strips the run that held the data.","commonSituations":"Conditional sub-workflow branches that produce no output for certain inputs; sub-workflows whose final node is an error-handling branch that returns []; misconfigured output routing.","solutions":["Open the sub-workflow and run it with the same input the agent sent; confirm output 0 emits ≥1 item.","Add a terminal Set node that always emits a default item (e.g. { response: 'No results' }).","If using 'Return All Items', ensure the sub-workflow's main output is a non-empty array.","Verify the sub-workflow's last executed node isn't on a dead branch."],"exampleFix":"// before: sub-workflow IF(false) → empty main branch → throws\n// after: merge both IF branches into a single terminal Set node\n//   that always emits { response: {{ $json.answer || 'No results' }} }","handlingStrategy":"validation","validationCode":"const slot = this.returnAllItems ? receivedData?.data?.[0] : receivedData?.data?.[0]?.[0]?.json;\nif (slot === undefined) throw new Error('Sub-workflow produced no output; add a terminal default item');","typeGuard":"function hasOutputItem(d: ExecuteWorkflowData, all: boolean): boolean {\n  return all ? (d?.data?.[0]?.length ?? 0) > 0 : d?.data?.[0]?.[0]?.json !== undefined;\n}","tryCatchPattern":"try { return await this.executeSubWorkflow(...); }\ncatch (e) { /* return a default response or rethrow with guidance */ }","preventionTips":["Ensure sub-workflow output 0 always has ≥1 item.","Add a terminal default Set node for edge-case branches.","Test the sub-workflow standalone with realistic inputs."],"tags":["workflow-tool","ai-tool","sub-workflow","empty-output"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}