fix: Fix paired item handling of multiple inputs (#16309)

This commit is contained in:
Elias Meire
2025-06-18 12:37:37 +02:00
committed by GitHub
parent 16b0297f85
commit 083073e541
4 changed files with 381 additions and 84 deletions

View File

@@ -0,0 +1,114 @@
{
"data": {
"startData": {},
"resultData": {
"runData": {
"Manual Trigger": [
{
"startTime": 1749486952181,
"executionIndex": 0,
"source": [],
"hints": [],
"executionTime": 2,
"executionStatus": "success",
"data": { "main": [[{ "json": {}, "pairedItem": { "item": 0 } }]] }
}
],
"Set main variable": [
{
"startTime": 1749486952183,
"executionIndex": 1,
"source": [{ "previousNode": "Manual Trigger" }],
"hints": [],
"executionTime": 2,
"executionStatus": "success",
"data": { "main": [[{ "json": { "main_variable": 2 }, "pairedItem": { "item": 0 } }]] }
}
],
"Set variable_1": [
{
"startTime": 1749486952185,
"executionIndex": 2,
"source": [{ "previousNode": "Set main variable" }],
"hints": [],
"executionTime": 0,
"executionStatus": "success",
"data": {
"main": [[{ "json": { "variable_1": "1234" }, "pairedItem": { "item": 0 } }]]
}
}
],
"Set variable_2": [
{
"startTime": 1749486952186,
"executionIndex": 3,
"source": [{ "previousNode": "Set main variable" }],
"hints": [],
"executionTime": 0,
"executionStatus": "success",
"data": {
"main": [[{ "json": { "variable_2": "2345" }, "pairedItem": { "item": 0 } }]]
}
}
],
"Set variable_3": [
{
"startTime": 1749486952187,
"executionIndex": 4,
"source": [{ "previousNode": "Set main variable" }],
"hints": [],
"executionTime": 0,
"executionStatus": "success",
"data": {
"main": [[{ "json": { "variable_3": "3456" }, "pairedItem": { "item": 0 } }]]
}
}
],
"Merge": [
{
"startTime": 1749486952197,
"executionIndex": 5,
"source": [null, null, { "previousNode": "Set variable_3" }],
"hints": [],
"executionTime": 12,
"executionStatus": "success",
"data": {
"main": [
[{ "json": { "variable_3": "3456" }, "pairedItem": { "item": 0, "input": 2 } }]
]
}
}
],
"Output": [
{
"startTime": 1749486952210,
"executionIndex": 6,
"source": [{ "previousNode": "Merge" }],
"hints": [],
"executionTime": 4,
"executionStatus": "success",
"data": {
"main": [
[
{
"json": { "final_variable_2": "3456", "main": "2" },
"pairedItem": { "item": 0 }
}
]
]
}
}
]
},
"pinData": {},
"lastNodeExecuted": "Output"
},
"executionData": {
"contextData": {},
"nodeExecutionStack": [],
"metadata": {},
"waitingExecution": {},
"waitingExecutionSource": {}
}
}
}

View File

@@ -0,0 +1,203 @@
{
"name": "Paired item",
"nodes": [
{
"parameters": {
"numberInputs": 3
},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.1,
"position": [560, 300],
"id": "2b68168b-1494-4c4b-b416-b4fb6bb0afd8",
"name": "Merge",
"alwaysOutputData": true
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "63830a30-a4cc-4a66-9d01-8f0a058d4d43",
"name": "variable_1",
"value": "1234",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [200, 100],
"id": "a1d151cc-8f44-43c6-962f-baecb879d33c",
"name": "Set variable_1"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "63830a30-a4cc-4a66-9d01-8f0a058d4d43",
"name": "variable_2",
"value": "2345",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [200, 300],
"id": "404ff876-b524-4873-8dc0-36664639907a",
"name": "Set variable_2"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "63830a30-a4cc-4a66-9d01-8f0a058d4d43",
"name": "variable_3",
"value": "3456",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [200, 500],
"id": "d403e979-7651-4acf-8e08-1d342b7abe7f",
"name": "Set variable_3"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "89862e7d-0c44-4d6a-897e-a249c06f6346",
"name": "final_variable_2",
"value": "={{ $('Set variable_3').item.json.variable_3 }}",
"type": "string"
},
{
"id": "060e841c-c236-41ae-9396-e23566825f47",
"name": "main",
"value": "={{ $('Set main variable').item.json.main_variable }}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [840, 300],
"id": "16514f79-e309-465c-b571-7d81e268d7f0",
"name": "Output"
},
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-240, 300],
"id": "3a8a9543-567c-443c-8742-fa0a8d9fb2e7",
"name": "Manual Trigger"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "6bb9d060-adee-429f-884d-5009ab1a1811",
"name": "main_variable",
"value": 2,
"type": "number"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [-20, 300],
"id": "b6ec9c0f-de04-45d3-a402-3969251a6914",
"name": "Set main variable"
}
],
"pinData": {},
"connections": {
"Merge": {
"main": [
[
{
"node": "Output",
"type": "main",
"index": 0
}
]
]
},
"Set variable_1": {
"main": [[]]
},
"Set variable_2": {
"main": [[]]
},
"Set variable_3": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 2
}
]
]
},
"Manual Trigger": {
"main": [
[
{
"node": "Set main variable",
"type": "main",
"index": 0
}
]
]
},
"Set main variable": {
"main": [
[
{
"node": "Set variable_2",
"type": "main",
"index": 0
},
{
"node": "Set variable_1",
"type": "main",
"index": 0
},
{
"node": "Set variable_3",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "5678abcc-b267-4b5b-ba1b-5f7bb1b085ec",
"meta": {
"instanceId": "27cc9b56542ad45b38725555722c50a1c3fee1670bbb67980558314ee08517c4"
},
"id": "TakJu1jBtMGTFXEA",
"tags": []
}

View File

@@ -835,4 +835,14 @@ describe('WorkflowDataProxy', () => {
expect(tools[0].aiDefinedFields).toEqual(['Start']);
});
});
describe('multiple inputs', () => {
const fixture = loadFixture('multiple_inputs');
it('should correctly resolve expressions with multiple inputs (using paired item)', () => {
const proxy = getProxyFromFixture(fixture.workflow, fixture.run, 'Output');
expect(proxy.$('Set variable_3').item.json.variable_3).toEqual('3456');
expect(proxy.$('Set main variable').item.json.main_variable).toEqual(2);
});
});
});