n8n-io/n8n · error · ValidationError
VALIDATION_ERROR
VALIDATION_ERROR
Error message
Invalid connection parameters
What it means
Zod schema validation failed on the input passed to connect_nodes. The schema (nodeConnectionSchema) requires sourceNodeId and targetNodeId as strings; sourceOutputIndex and targetInputIndex are optional numbers. Any deviation throws a ZodError which the catch block relabels as VALIDATION_ERROR with the original issue list in details.
Source
Thrown at packages/@n8n/ai-workflow-builder.ee/src/tools/connect-nodes.tool.ts:290
},
};
reporter.complete(output);
// Return success with state updates
const stateUpdates = updateWorkflowConnections(newConnection);
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 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: CONNECT_NODES_TOOL.toolName,
description: `Connect two nodes in the workflow. The tool automatically determines the connection type based on node capabilities and ensures correct connection direction.
UNDERSTANDING CONNECTIONS:View on GitHub (pinned to 5ac6606e81)
Solutions
- Read details (the ZodError.issues array) to find the first failing path and message.
- Ensure sourceNodeId and targetNodeId are UUID strings and indices are numbers or omitted.
- Re-invoke connect_nodes with corrected input.
Example fix
// before
connect_nodes.invoke({ sourceNodeId: { id: 'abc' }, targetNodeId: 'def' });
// after
connect_nodes.invoke({ sourceNodeId: 'abc-1234', targetNodeId: 'def-5678' }); Defensive patterns
Strategy: validation
Validate before calling
import { nodeConnectionSchema } from '@/tools/connect-nodes.tool';
// Validate input with the same schema before invoking the tool.
const parsed = nodeConnectionSchema.safeParse(input);
if (!parsed.success) {
// surface parsed.error.issues to the caller / LLM and skip the tool call
} Type guard
function isValidConnectInput(v: unknown): v is { sourceNodeId: string; targetNodeId: 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
// ZodError is caught internally; the tool returns a structured VALIDATION_ERROR.
// If invoking the raw schema yourself:
try {
nodeConnectionSchema.parse(input);
} catch (e) {
if (e instanceof z.ZodError) { /* e.issues has field-level detail */ }
} Prevention
- Always run the tool's exported Zod schema with safeParse before invoking.
- Type the agent's tool-call arguments from the schema's inferred type.
- Reject empty or non-string IDs upstream of the tool.
When it happens
Trigger: Missing sourceNodeId or targetNodeId; passing a non-string (object/number) for an ID; passing a string for sourceOutputIndex; passing undefined for a required field.
Common situations: The LLM agent omits a field, passes an object like { id: '...' } instead of the UUID string, or sends indices as strings from a form payload.
Related errors
- VALIDATION_ERROR
- VALIDATION_ERROR
- Tool "${this.name}" requires an input schema
- INVALID_CONNECTION
- SELF_CONNECTION
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/86f56f8ccc93de25.
Report an issue: GitHub.