Flow executes random node

Describe the issue/error/question

When I execute the flow everything goes fine until at some point it executes a random node, in this case the one named: Create JSON-items2. There is no conditions in the flow to execute that node.

What is the error message (if any)?

TypeError: Cannot read properties of undefined (reading 'map')
    at /Applications/n8n.app/Contents/Resources/app/node_modules/n8n-nodes-base/dist/nodes/Function:1:124
    at /Applications/n8n.app/Contents/Resources/app/node_modules/n8n-nodes-base/dist/nodes/Function:6:2
    at BaseHandler.apply (/Applications/n8n.app/Contents/Resources/app/node_modules/vm2/lib/bridge.js:479:11)
    at NodeVM.run (/Applications/n8n.app/Contents/Resources/app/node_modules/vm2/lib/nodevm.js:425:23)
    at Object.execute (/Applications/n8n.app/Contents/Resources/app/node_modules/n8n-nodes-base/dist/nodes/Function/Function.node.js:96:31)
    at Workflow.runNode (/Applications/n8n.app/Contents/Resources/app/node_modules/n8n-workflow/dist/src/Workflow.js:594:51)
    at /Applications/n8n.app/Contents/Resources/app/node_modules/n8n-core/dist/src/WorkflowExecute.js:537:64
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Please share the workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.6.0.
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Mac Desktop App

Hey @Nelson_Paz_y_Mino,

Do you have a screenshot from the execution log showing the issue? I suspect the issue is coming from the merge node further down but without seeing the paths in the UI it is hard to say.

Hello, Jon. Please check the screenshots below:

Hey @Nelson_Paz_y_Mino,

Perfect so looking at that I suspect the issue is coming from the merge node trying to get an input 1 as nothing else is going to the input 2 of the other merge node and that is where it is checking.

Looking at the workflow you could maybe put in some extra logic to allow for values not existing but I think what I would do is start reworking it and seeing where things can be simplified.

Thanks Jon, the thing is that Input 2 has data to be sent to the Merge node. Input 1 has around 6500 rows and Input 2 around 3500. So it’s weird that the Merge node tries to get more data from Input 1. If just switch nodes (Input 1 to have around 3500 rows and Input 2 around 6500.), it works perfectly.