n8n-io/n8n · error · ValidationError

VALIDATION_ERROR

VALIDATION_ERROR

Error message

Invalid connection removal parameters

What it means

Zod schema validation failed on the input to remove_connection. The schema (removeConnectionSchema) requires sourceNodeId and targetNodeId as strings; connectionType defaults to 'main'; sourceOutputIndex and targetInputIndex default to 0. The catch block relabels the ZodError as VALIDATION_ERROR.

Solutions

  1. Read details (ZodError.issues) for the first failing path.
  2. Pass UUID strings for both IDs and numbers (or omit) for indices.
  3. Re-invoke remove_connection with corrected input.

Example fix

// before
remove_connection.invoke({ source: 'abc', target: 'def' }); // wrong keys
// after
remove_connection.invoke({ sourceNodeId: 'abc', targetNodeId: 'def' });
Defensive patterns

Strategy: validation

Validate before calling

import { removeConnectionSchema } from '@/tools/remove-connection.tool';

const parsed = removeConnectionSchema.safeParse(input);
if (!parsed.success) { /* surface parsed.error.issues, skip the tool call */ }

Type guard

function isValidRemoveInput(v: unknown): v is { sourceNodeId: string; targetNodeId: string; connectionType?: string; sourceOutputIndex?: number; targetInputIndex?: number } {
  return typeof v === 'object' && v !== null
    && typeof (v as any).sourceNodeId === 'string'
    && typeof (v as any).targetNodeId === 'string';
}

Try / catch

try {
  removeConnectionSchema.parse(input);
} catch (e) {
  if (e instanceof z.ZodError) { /* e.issues has field-level detail */ }
}

Prevention

When it happens

Trigger: Missing sourceNodeId or targetNodeId; non-string IDs; non-numeric indices; connectionType passed as a non-string.

Common situations: The LLM omits a required field; indices provided as strings; an object passed instead of a UUID.

Related errors


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

Appendix: source

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

					sourceNode.name,
					targetNode.name,
					validatedInput.connectionType,
					validatedInput.sourceOutputIndex,
					validatedInput.targetInputIndex,
				);
				return createSuccessResponse(config, message, stateUpdates);
			} catch (error) {
				// Handle validation or unexpected errors
				let toolError;

				if (error instanceof z.ZodError) {
					const validationError = new ValidationError('Invalid connection removal parameters', {
						field: error.errors[0]?.path.join('.'),
						value: error.errors[0]?.message,
					});
					toolError = {
						message: validationError.message,
						code: 'VALIDATION_ERROR',
						details: error.errors,
					};
				} else {
					toolError = {
						message: error instanceof Error ? error.message : 'Unknown error occurred',
						code: 'EXECUTION_ERROR',
					};
				}

				reporter.error(toolError);
				return createErrorResponse(config, toolError);
			}
		},
		{
			name: REMOVE_CONNECTION_TOOL.toolName,
			description: `Remove a specific connection between two nodes in the workflow. This allows you to disconnect nodes without deleting them.

USAGE:

View on GitHub (pinned to 5ac6606e81)