fix(Execute Sub-workflow Node): Improve paired item handling for child workflows (#17065)

This commit is contained in:
Andreas Fitzek
2025-07-09 11:01:57 +02:00
committed by GitHub
parent 62ea048bbf
commit f5fb33a3fa
6 changed files with 679 additions and 1 deletions

View File

@@ -7,10 +7,12 @@ import type {
INodeTypeDescription,
} from 'n8n-workflow';
import { findPairedItemTroughWorkflowData } from './../../../utils/workflow-backtracking';
import { getWorkflowInfo } from './GenericFunctions';
import { localResourceMapping } from './methods';
import { generatePairedItemData } from '../../../utils/utilities';
import { getCurrentWorkflowInputData } from '../../../utils/workflowInputsResourceMapping/GenericFunctions';
export class ExecuteWorkflow implements INodeType {
description: INodeTypeDescription = {
displayName: 'Execute Sub-workflow',
@@ -425,6 +427,8 @@ export class ExecuteWorkflow implements INodeType {
return [items];
}
const workflowRunData = await this.getExecutionDataById(executionResult.executionId);
const workflowResult = executionResult.data as INodeExecutionData[][];
const fallbackPairedItemData = generatePairedItemData(items.length);
@@ -433,7 +437,20 @@ export class ExecuteWorkflow implements INodeType {
const sameLength = output.length === items.length;
for (const [itemIndex, item] of output.entries()) {
if (item.pairedItem) continue;
if (item.pairedItem) {
// If the item already has a paired item, we need to follow these to the start of the child workflow
if (workflowRunData !== undefined) {
const pairedItem = findPairedItemTroughWorkflowData(
workflowRunData,
item,
itemIndex,
);
if (pairedItem !== undefined) {
item.pairedItem = pairedItem;
}
}
continue;
}
if (sameLength) {
item.pairedItem = { item: itemIndex };