n8n-io/n8n · warning · ConnectionError

OUTPUT_INDEX_NOT_FOUND

OUTPUT_INDEX_NOT_FOUND

Error message

Source node "${sourceNode.name}" has no connections at output index ${validatedInput.sourceOutputIndex}

What it means

The remove-connection tool found the source node's connections for the given connection type, but the array at the requested sourceOutputIndex is missing or not an array — i.e. that output branch has no connections to remove. Wrapped in a ConnectionError with from/to node IDs and returned as a structured tool error.

Solutions

  1. Check availableConnectionTypes in the preceding error details and use an output index that actually has connections
  2. List the node's current connections first to pick the correct sourceOutputIndex
  3. If the connection was already removed in an earlier step, treat the workflow state as already correct

Example fix

// before
remove_connection.invoke({ ..., sourceOutputIndex: 1 });
// after
remove_connection.invoke({ ..., sourceOutputIndex: 0 });
Defensive patterns

Strategy: validation

Validate before calling

// Check the branch at sourceOutputIndex before removing.
const branches = workflow.connections[sourceNode.name]?.[connectionType] ?? [];
if (!Array.isArray(branches[sourceOutputIndex]) || branches[sourceOutputIndex].length === 0) {
  // pick a populated index or default to 0
}

Try / catch

const res = await remove_connection.invoke(input);
if (isToolError(res) && res.code === 'OUTPUT_INDEX_NOT_FOUND') {
  // lower sourceOutputIndex or inspect the node's outputs
}

Prevention

When it happens

Trigger: Calling remove_connection with sourceOutputIndex: 1 when only index 0 has connections; off-by-one in index selection.

Common situations: IF node false-branch (index 1) was never wired; Switch node rule index miscounted; the branch was already disconnected.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/fcd3c87cc44b6f0e. Report an issue: GitHub.

Appendix: source

Thrown at packages/@n8n/ai-workflow-builder.ee/src/tools/remove-connection.tool.ts:187

							availableConnectionTypes: Object.keys(sourceConnections),
						},
					};
					reporter.error(error);
					return createErrorResponse(config, error);
				}

				const outputConnections = connectionTypeOutputs[validatedInput.sourceOutputIndex];
				if (!outputConnections || !Array.isArray(outputConnections)) {
					const connectionError = new ConnectionError(
						`Source node "${sourceNode.name}" has no connections at output index ${validatedInput.sourceOutputIndex}`,
						{
							fromNodeId: sourceNode.id,
							toNodeId: targetNode.id,
						},
					);
					const error = {
						message: connectionError.message,
						code: 'OUTPUT_INDEX_NOT_FOUND',
						details: {
							sourceNode: sourceNode.name,
							targetNode: targetNode.name,
							connectionType: validatedInput.connectionType,
							sourceOutputIndex: validatedInput.sourceOutputIndex,
						},
					};
					reporter.error(error);
					return createErrorResponse(config, error);
				}

				// Check if the specific connection exists
				const connectionExists = outputConnections.some(
					(conn) =>
						conn.node === targetNode.name &&
						conn.type === validatedInput.connectionType &&
						conn.index === validatedInput.targetInputIndex,
				);

View on GitHub (pinned to 5ac6606e81)