{"record":{"id":"86f56f8ccc93de25","repo":"n8n-io/n8n","slug":"validation-error","errorCode":"VALIDATION_ERROR","errorMessage":"Invalid connection parameters","messagePattern":"Invalid connection parameters","errorType":"error_code","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/ai-workflow-builder.ee/src/tools/connect-nodes.tool.ts","lineNumber":290,"sourceCode":"\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treporter.complete(output);\n\n\t\t\t\t// Return success with state updates\n\t\t\t\tconst stateUpdates = updateWorkflowConnections(newConnection);\n\t\t\t\treturn createSuccessResponse(config, message, stateUpdates);\n\t\t\t} catch (error) {\n\t\t\t\t// Handle validation or unexpected errors\n\t\t\t\tlet toolError;\n\n\t\t\t\tif (error instanceof z.ZodError) {\n\t\t\t\t\tconst validationError = new ValidationError('Invalid connection parameters', {\n\t\t\t\t\t\tfield: error.errors[0]?.path.join('.'),\n\t\t\t\t\t\tvalue: error.errors[0]?.message,\n\t\t\t\t\t});\n\t\t\t\t\ttoolError = {\n\t\t\t\t\t\tmessage: validationError.message,\n\t\t\t\t\t\tcode: 'VALIDATION_ERROR',\n\t\t\t\t\t\tdetails: error.errors,\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\ttoolError = {\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : 'Unknown error occurred',\n\t\t\t\t\t\tcode: 'EXECUTION_ERROR',\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treporter.error(toolError);\n\t\t\t\treturn createErrorResponse(config, toolError);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tname: CONNECT_NODES_TOOL.toolName,\n\t\t\tdescription: `Connect two nodes in the workflow. The tool automatically determines the connection type based on node capabilities and ensures correct connection direction.\n\nUNDERSTANDING CONNECTIONS:","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-workflow-builder.ee/src/tools/connect-nodes.tool.ts#L272-L308","documentation":"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.","triggerScenarios":"Missing sourceNodeId or targetNodeId; passing a non-string (object/number) for an ID; passing a string for sourceOutputIndex; passing undefined for a required field.","commonSituations":"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.","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."],"exampleFix":"// before\nconnect_nodes.invoke({ sourceNodeId: { id: 'abc' }, targetNodeId: 'def' });\n// after\nconnect_nodes.invoke({ sourceNodeId: 'abc-1234', targetNodeId: 'def-5678' });","handlingStrategy":"validation","validationCode":"import { nodeConnectionSchema } from '@/tools/connect-nodes.tool';\n\n// Validate input with the same schema before invoking the tool.\nconst parsed = nodeConnectionSchema.safeParse(input);\nif (!parsed.success) {\n  // surface parsed.error.issues to the caller / LLM and skip the tool call\n}","typeGuard":"function isValidConnectInput(v: unknown): v is { sourceNodeId: string; targetNodeId: string; sourceOutputIndex?: number; targetInputIndex?: number } {\n  return typeof v === 'object' && v !== null\n    && typeof (v as any).sourceNodeId === 'string'\n    && typeof (v as any).targetNodeId === 'string';\n}","tryCatchPattern":"// ZodError is caught internally; the tool returns a structured VALIDATION_ERROR.\n// If invoking the raw schema yourself:\ntry {\n  nodeConnectionSchema.parse(input);\n} catch (e) {\n  if (e instanceof z.ZodError) { /* e.issues has field-level detail */ }\n}","preventionTips":["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."],"tags":["workflow-builder","validation","zod","input"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}