mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix: Fix paired item for Merge node with mode=chooseBranch (#16552)
This commit is contained in:
@@ -28,6 +28,7 @@ import type {
|
|||||||
INode,
|
INode,
|
||||||
} from './interfaces';
|
} from './interfaces';
|
||||||
import * as NodeHelpers from './node-helpers';
|
import * as NodeHelpers from './node-helpers';
|
||||||
|
import { createResultError, createResultOk } from './result';
|
||||||
import { isResourceLocatorValue } from './type-guards';
|
import { isResourceLocatorValue } from './type-guards';
|
||||||
import { deepCopy, isObjectEmpty } from './utils';
|
import { deepCopy, isObjectEmpty } from './utils';
|
||||||
import type { Workflow } from './workflow';
|
import type { Workflow } from './workflow';
|
||||||
@@ -966,21 +967,34 @@ export class WorkflowDataProxy {
|
|||||||
if (inputIndex >= sourceArray.length) return [];
|
if (inputIndex >= sourceArray.length) return [];
|
||||||
|
|
||||||
const nextSource = nextPairedItem.sourceOverwrite ?? sourceArray[inputIndex];
|
const nextSource = nextPairedItem.sourceOverwrite ?? sourceArray[inputIndex];
|
||||||
return getPairedItem(
|
|
||||||
|
try {
|
||||||
|
return createResultOk(
|
||||||
|
getPairedItem(
|
||||||
destinationNodeName,
|
destinationNodeName,
|
||||||
nextSource,
|
nextSource,
|
||||||
{ ...nextPairedItem, input: inputIndex },
|
{ ...nextPairedItem, input: inputIndex },
|
||||||
usedMethodName,
|
usedMethodName,
|
||||||
sourceData.previousNode,
|
sourceData.previousNode,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return createResultError(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (results.length === 0) {
|
if (results.every((result) => !result.ok)) {
|
||||||
|
throw results[0].error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchedItems = results.filter((result) => result.ok).map((result) => result.result);
|
||||||
|
|
||||||
|
if (matchedItems.length === 0) {
|
||||||
if (sourceArray.length === 0) throw createNoConnectionError(destinationNodeName);
|
if (sourceArray.length === 0) throw createNoConnectionError(destinationNodeName);
|
||||||
throw createBranchNotFoundError(sourceData.previousNode, pairedItem.item, nodeBeforeLast);
|
throw createBranchNotFoundError(sourceData.previousNode, pairedItem.item, nodeBeforeLast);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [first, ...rest] = results;
|
const [first, ...rest] = matchedItems;
|
||||||
if (rest.some((r) => r !== first)) {
|
if (rest.some((r) => r !== first)) {
|
||||||
throw createPairedItemMultipleItemsFound(destinationNodeName, pairedItem.item);
|
throw createPairedItemMultipleItemsFound(destinationNodeName, pairedItem.item);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user