mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-03-19 00:43:07 +00:00
fix: CRITICAL - branch parameter now correctly maps to sourceIndex, not sourceOutput
Found by n8n-mcp-tester agent: IF nodes in n8n store connections as: IF.main[0] (true branch) IF.main[1] (false branch) NOT as IF.true and IF.false Previous implementation (WRONG): - branch='true' → sourceOutput='true' Correct implementation (FIXED): - branch='true' → sourceIndex=0, sourceOutput='main' - branch='false' → sourceIndex=1, sourceOutput='main' Changes: - resolveSmartParameters(): branch now sets sourceIndex, not sourceOutput - Type definition comments updated to reflect correct mapping - All unit tests fixed to expect connections under 'main' with correct indices - All 141 tests passing with correct behavior This was caught by integration testing against real n8n API, not by unit tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -648,10 +648,12 @@ export class WorkflowDiffEngine {
|
||||
let sourceIndex = operation.sourceIndex ?? 0;
|
||||
|
||||
// Smart parameter: branch (for IF nodes)
|
||||
if (operation.branch && !operation.sourceOutput) {
|
||||
// Only apply if sourceOutput not explicitly set
|
||||
// IF nodes use 'main' output with index 0 (true) or 1 (false)
|
||||
if (operation.branch !== undefined && operation.sourceIndex === undefined) {
|
||||
// Only apply if sourceIndex not explicitly set
|
||||
if (sourceNode?.type === 'n8n-nodes-base.if') {
|
||||
sourceOutput = operation.branch; // 'true' or 'false'
|
||||
sourceIndex = operation.branch === 'true' ? 0 : 1;
|
||||
// sourceOutput remains 'main' (do not change it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user