mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
fix(core): Fix pairedItem for alwaysOutputData & multi identical resolve (#6405)
This commit is contained in:
@@ -20,6 +20,7 @@ import type {
|
||||
INode,
|
||||
INodeConnections,
|
||||
INodeExecutionData,
|
||||
IPairedItemData,
|
||||
IPinData,
|
||||
IRun,
|
||||
IRunData,
|
||||
@@ -971,32 +972,35 @@ export class WorkflowExecute {
|
||||
workflowId: workflow.id,
|
||||
});
|
||||
|
||||
if (nodeSuccessData) {
|
||||
// Check if the output data contains pairedItem data
|
||||
if (nodeSuccessData?.length) {
|
||||
// Check if the output data contains pairedItem data and if not try
|
||||
// to automatically fix it
|
||||
|
||||
const isSingleInputAndOutput =
|
||||
executionData.data.main.length === 1 && executionData.data.main[0]?.length === 1;
|
||||
|
||||
const isSameNumberOfItems =
|
||||
nodeSuccessData.length === 1 &&
|
||||
executionData.data.main.length === 1 &&
|
||||
executionData.data.main[0]?.length === nodeSuccessData[0].length;
|
||||
|
||||
checkOutputData: for (const outputData of nodeSuccessData) {
|
||||
if (outputData === null) {
|
||||
continue;
|
||||
}
|
||||
for (const [index, item] of outputData.entries()) {
|
||||
if (!item.pairedItem) {
|
||||
if (item.pairedItem === undefined) {
|
||||
// The pairedItem data is missing, so check if it can get automatically fixed
|
||||
if (
|
||||
executionData.data.main.length === 1 &&
|
||||
executionData.data.main[0]?.length === 1
|
||||
) {
|
||||
if (isSingleInputAndOutput) {
|
||||
// The node has one input and one incoming item, so we know
|
||||
// that all items must originate from that single
|
||||
item.pairedItem = {
|
||||
item: 0,
|
||||
};
|
||||
} else if (
|
||||
nodeSuccessData.length === 1 &&
|
||||
executionData.data.main.length === 1 &&
|
||||
executionData.data.main[0]?.length === nodeSuccessData[0].length
|
||||
) {
|
||||
// The node has one input and one output. The number of items on both is
|
||||
// identical so we can make the reasonable assumption that each of the input
|
||||
// items is the origin of the corresponding output items
|
||||
} else if (isSameNumberOfItems) {
|
||||
// The number of oncoming and outcoming items is identical so we can
|
||||
// make the reasonable assumption that each of the input items
|
||||
// is the origin of the corresponding output items
|
||||
item.pairedItem = {
|
||||
item: index,
|
||||
};
|
||||
@@ -1018,10 +1022,26 @@ export class WorkflowExecute {
|
||||
|
||||
if (nodeSuccessData === null || nodeSuccessData[0][0] === undefined) {
|
||||
if (executionData.node.alwaysOutputData === true) {
|
||||
const pairedItem: IPairedItemData[] = [];
|
||||
|
||||
// Get pairedItem from all input items
|
||||
executionData.data.main.forEach((inputData, inputIndex) => {
|
||||
if (!inputData) {
|
||||
return;
|
||||
}
|
||||
inputData.forEach((item, itemIndex) => {
|
||||
pairedItem.push({
|
||||
item: itemIndex,
|
||||
input: inputIndex,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
nodeSuccessData = nodeSuccessData || [];
|
||||
nodeSuccessData[0] = [
|
||||
{
|
||||
json: {},
|
||||
pairedItem,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user