From 44568a6edd93794ac5ebaff1e1f2476e7e4b1569 Mon Sep 17 00:00:00 2001 From: czlonkowski <56956555+czlonkowski@users.noreply.github.com> Date: Mon, 6 Oct 2025 08:15:01 +0200 Subject: [PATCH] fix: improve rewireConnection validation to check specific sourceIndex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses code review feedback - rewireConnection now validates that a connection exists at the SPECIFIC sourceIndex, not just at any index. Problem: - Previous validation checked if connection existed at ANY index - Could cause confusing runtime errors instead of clear validation errors - Example: Connection exists at index 0, but rewireConnection uses index 1 Fix: - Resolve smart parameters to get actual sourceIndex - Validate connection exists at connections[sourceOutput][sourceIndex] - Provide clear error message with specific index Impact: - Better validation error messages - Prevents confusing runtime errors - Clearer feedback to AI agents Code Review: High priority fix from @agent-code-reviewer 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/services/workflow-diff-engine.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/services/workflow-diff-engine.ts b/src/services/workflow-diff-engine.ts index f046580..b659145 100644 --- a/src/services/workflow-diff-engine.ts +++ b/src/services/workflow-diff-engine.ts @@ -484,20 +484,22 @@ export class WorkflowDiffEngine { } // Resolve smart parameters (branch, case) before validating connections - const { sourceOutput } = this.resolveSmartParameters(workflow, operation); + const { sourceOutput, sourceIndex } = this.resolveSmartParameters(workflow, operation); - // Validate that connection from source to "from" exists + // Validate that connection from source to "from" exists at the specific index const connections = workflow.connections[sourceNode.name]?.[sourceOutput]; if (!connections) { return `No connections found from "${sourceNode.name}" on output "${sourceOutput}"`; } - const hasConnection = connections.some(conns => - conns.some(c => c.node === fromNode.name) - ); + if (!connections[sourceIndex]) { + return `No connections found from "${sourceNode.name}" on output "${sourceOutput}" at index ${sourceIndex}`; + } + + const hasConnection = connections[sourceIndex].some(c => c.node === fromNode.name); if (!hasConnection) { - return `No connection exists from "${sourceNode.name}" to "${fromNode.name}" on output "${sourceOutput}"`; + return `No connection exists from "${sourceNode.name}" to "${fromNode.name}" on output "${sourceOutput}" at index ${sourceIndex}"`; } return null;