fix(Execute Workflow Node): Pass binary data to sub-workflow (#12635)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Charlie Kolb 2025-01-16 13:04:06 +01:00 committed by GitHub
parent 35cb10c5e7
commit e9c152e369
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 66 additions and 2 deletions

View file

@ -97,7 +97,7 @@ export function getFieldEntries(context: IWorkflowNodeContext): FieldValueOption
export function getWorkflowInputValues(this: ISupplyDataFunctions): INodeExecutionData[] {
const inputData = this.getInputData();
return inputData.map((item, itemIndex) => {
return inputData.map(({ json, binary }, itemIndex) => {
const itemFieldValues = this.getNodeParameter(
'workflowInputs.value',
itemIndex,
@ -106,13 +106,14 @@ export function getWorkflowInputValues(this: ISupplyDataFunctions): INodeExecuti
return {
json: {
...item.json,
...json,
...itemFieldValues,
},
index: itemIndex,
pairedItem: {
item: itemIndex,
},
binary,
};
});
}

View file

@ -0,0 +1,63 @@
import { mock } from 'jest-mock-extended';
import type { ISupplyDataFunctions } from 'n8n-workflow';
import { getWorkflowInputValues } from '../GenericFunctions';
describe('getWorkflowInputValues', () => {
const supplyDataFunctions = mock<ISupplyDataFunctions>();
it('should correctly map the binary property', () => {
supplyDataFunctions.getInputData.mockReturnValue([
{
json: { key1: 'value1' },
binary: { file1: { data: 'binaryData1', mimeType: 'image/png' } },
},
{
json: { key2: 'value2' },
binary: { file2: { data: 'binaryData2', mimeType: 'image/jpeg' } },
},
]);
supplyDataFunctions.getNodeParameter
.calledWith('workflowInputs.value', 0)
.mockReturnValueOnce({ additionalKey1: 'additionalValue1' });
supplyDataFunctions.getNodeParameter
.calledWith('workflowInputs.value', 1)
.mockReturnValueOnce({ additionalKey2: 'additionalValue2' });
const result = getWorkflowInputValues.call(supplyDataFunctions);
expect(result).toEqual([
{
json: {
key1: 'value1',
additionalKey1: 'additionalValue1',
},
binary: { file1: { data: 'binaryData1', mimeType: 'image/png' } },
index: 0,
pairedItem: { item: 0 },
},
{
json: {
key2: 'value2',
additionalKey2: 'additionalValue2',
},
binary: { file2: { data: 'binaryData2', mimeType: 'image/jpeg' } },
index: 1,
pairedItem: { item: 1 },
},
]);
expect(supplyDataFunctions.getInputData).toHaveBeenCalled();
expect(supplyDataFunctions.getNodeParameter).toHaveBeenCalledWith(
'workflowInputs.value',
0,
{},
);
expect(supplyDataFunctions.getNodeParameter).toHaveBeenCalledWith(
'workflowInputs.value',
1,
{},
);
});
});