{"record":{"id":"d4110800a68a98f7","repo":"n8n-io/n8n","slug":"there-was-an-error-the-workflow-did-not-return-a","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/v1/ToolWorkflowV1.node.ts","lineNumber":139,"sourceCode":"\t\t\t\treceivedData = await this.executeWorkflow(workflowInfo, items, runManager?.getChild(), {\n\t\t\t\t\tparentExecution: {\n\t\t\t\t\t\texecutionId: workflowProxy.$execution.id,\n\t\t\t\t\t\tworkflowId: workflowProxy.$workflow.id,\n\t\t\t\t\t},\n\t\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\t});\n\t\t\t\tsubExecutionId = receivedData.executionId;\n\t\t\t} catch (error) {\n\t\t\t\t// Make sure a valid error gets returned that can by json-serialized else it will\n\t\t\t\t// not show up in the frontend\n\t\t\t\tthrow new NodeOperationError(this.getNode(), error as Error);\n\t\t\t}\n\n\t\t\tconst response: string | undefined = get(receivedData, 'data[0][0].json') as\n\t\t\t\t| string\n\t\t\t\t| undefined;\n\t\t\tif (response === undefined) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t'There was an error: \"The workflow did not return a response\"',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst toolHandler = async (\n\t\t\tquery: string | IDataObject,\n\t\t\trunManager?: CallbackManagerForToolRun,\n\t\t): Promise<string> => {\n\t\t\tconst { index } = this.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);\n\n\t\t\tlet response: string = '';\n\t\t\tlet executionError: ExecutionError | undefined;\n\t\t\ttry {\n\t\t\t\tresponse = await runFunction(query, runManager);","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v1/ToolWorkflowV1.node.ts#L121-L157","documentation":"Thrown by the Call Workflow Tool v1 after the sub-workflow executes successfully but receivedData.data[0][0].json is undefined — i.e. the sub-workflow produced no output item on its first output of its last run. The tool requires a concrete response item to hand back to the agent.","triggerScenarios":"The sub-workflow ends in a node that outputs nothing (e.g. an IF branch that takes the empty path, a Code node returning [], or a Stop node); the sub-workflow's last node is disabled or errored silently; the response is on a different output than output 0.","commonSituations":"Sub-workflow logic that conditionally produces no items; routing the real answer to a non-zero output; a sub-workflow that relies on 'Respond to Webhook' instead of returning data.","solutions":["Open the sub-workflow and ensure the final node on the main output emits at least one item for the test input.","Add a fallback/Set node at the end that always emits a default response item.","If using a Chat Trigger sub-workflow, make sure a 'Respond to Agent' / output node is the terminal node.","Check the sub-workflow execution log to see which branch produced empty output."],"exampleFix":"// before: sub-workflow IF → empty branch → no item → tool throws\n// after: add a default-branch Set node at the end:\n// Set node: { response: 'No results' }\n// always connected as the terminal node.","handlingStrategy":"validation","validationCode":"const resp = get(receivedData, 'data[0][0].json');\nif (resp === undefined) {\n  // ensure the sub-workflow emits a default item, or surface a friendly message\n  throw new Error('Sub-workflow returned no output item; add a terminal Set node');\n}","typeGuard":"function subWorkflowReturnedData(d: ExecuteWorkflowData): boolean {\n  return Array.isArray(d?.data?.[0]) && d.data[0].length > 0 && d.data[0][0]?.json !== undefined;\n}","tryCatchPattern":"try { response = await runFunction(query, runManager); }\ncatch (e) { response = 'There was an error: ...'; /* graceful agent-facing fallback */ }","preventionTips":["Design sub-workflows to always emit at least one item on output 0.","Add a terminal default-response Set node.","Test the sub-workflow standalone with realistic inputs before wiring it as a tool."],"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-12T18:17:37.767Z"}