{"record":{"id":"fcd3c87cc44b6f0e","repo":"n8n-io/n8n","slug":"output-index-not-found","errorCode":"OUTPUT_INDEX_NOT_FOUND","errorMessage":"Source node \"${sourceNode.name}\" has no connections at output index ${validatedInput.sourceOutputIndex}","messagePattern":"Source node \"(.+?)\" has no connections at output index (.+?)","errorType":"error_code","errorClass":"ConnectionError","httpStatus":null,"severity":"warning","filePath":"packages/@n8n/ai-workflow-builder.ee/src/tools/remove-connection.tool.ts","lineNumber":187,"sourceCode":"\t\t\t\t\t\t\tavailableConnectionTypes: Object.keys(sourceConnections),\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\treporter.error(error);\n\t\t\t\t\treturn createErrorResponse(config, error);\n\t\t\t\t}\n\n\t\t\t\tconst outputConnections = connectionTypeOutputs[validatedInput.sourceOutputIndex];\n\t\t\t\tif (!outputConnections || !Array.isArray(outputConnections)) {\n\t\t\t\t\tconst connectionError = new ConnectionError(\n\t\t\t\t\t\t`Source node \"${sourceNode.name}\" has no connections at output index ${validatedInput.sourceOutputIndex}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfromNodeId: sourceNode.id,\n\t\t\t\t\t\t\ttoNodeId: targetNode.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tconst error = {\n\t\t\t\t\t\tmessage: connectionError.message,\n\t\t\t\t\t\tcode: 'OUTPUT_INDEX_NOT_FOUND',\n\t\t\t\t\t\tdetails: {\n\t\t\t\t\t\t\tsourceNode: sourceNode.name,\n\t\t\t\t\t\t\ttargetNode: targetNode.name,\n\t\t\t\t\t\t\tconnectionType: validatedInput.connectionType,\n\t\t\t\t\t\t\tsourceOutputIndex: validatedInput.sourceOutputIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\treporter.error(error);\n\t\t\t\t\treturn createErrorResponse(config, error);\n\t\t\t\t}\n\n\t\t\t\t// Check if the specific connection exists\n\t\t\t\tconst connectionExists = outputConnections.some(\n\t\t\t\t\t(conn) =>\n\t\t\t\t\t\tconn.node === targetNode.name &&\n\t\t\t\t\t\tconn.type === validatedInput.connectionType &&\n\t\t\t\t\t\tconn.index === validatedInput.targetInputIndex,\n\t\t\t\t);","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-workflow-builder.ee/src/tools/remove-connection.tool.ts#L169-L205","documentation":"remove_connection drilled into sourceConnections[connectionType] and found that the entry at sourceOutputIndex is missing or not an array. The requested output branch has no connections.","triggerScenarios":"Calling remove_connection with sourceOutputIndex: 1 when only index 0 has connections; off-by-one in index selection.","commonSituations":"IF node false-branch (index 1) was never wired; Switch node rule index miscounted; the branch was already disconnected.","solutions":["Lower sourceOutputIndex to a populated branch (typically 0).","Inspect the node's outputs via get_node_details to find which indices have connections.","Re-issue with the correct index or default (0)."],"exampleFix":"// before\nremove_connection.invoke({ ..., sourceOutputIndex: 1 });\n// after\nremove_connection.invoke({ ..., sourceOutputIndex: 0 });","handlingStrategy":"validation","validationCode":"// Check the branch at sourceOutputIndex before removing.\nconst branches = workflow.connections[sourceNode.name]?.[connectionType] ?? [];\nif (!Array.isArray(branches[sourceOutputIndex]) || branches[sourceOutputIndex].length === 0) {\n  // pick a populated index or default to 0\n}","typeGuard":null,"tryCatchPattern":"const res = await remove_connection.invoke(input);\nif (isToolError(res) && res.code === 'OUTPUT_INDEX_NOT_FOUND') {\n  // lower sourceOutputIndex or inspect the node's outputs\n}","preventionTips":["Default sourceOutputIndex to 0 unless the branch is known.","For IF nodes, remember index 0 = true, 1 = false; only pass 1 if the false branch is wired.","Inspect node output wiring via get_node_details before disconnecting a specific branch."],"tags":["workflow-builder","connections","indices","remove"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}