Merging paths with empty item

I have the following setup. It gets passed some items and based if a property is set the if node decides if the “update” or the "create path is taken. If the “Update Moco Company” node is successfully executed, it returns the same input as originally input - of course updated.

What i am trying to achieve is to always get back the input items in the updated state if applicable. Thats why I merge the input items at the bottom path and the merge node is configured to only keep items of input 1. The output of that merge is than merged with the output of the update path at the top. i think conceptionally this should work.

However, there might be cases where there are no updates or no creates at all. Meaning, one path might not return anything. The merge will never work. Even when setting the nodes to always return an output, the merge node still cannot combine the inputs since the item on one path will be an empty object.

The other thing I do not get is why the upper path is executed once when no items passed the true case of the if node.

Thank you very much for any feedback. I am really having a hard time wrapping my head around this.

Information on your n8n setup

  • n8n version:0.225.1
  • Database (default: SQLite):postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):cloudron

You could try using the new Compare Datasets node. If there is no match on either side it will go to a dedicated output. I just had to replace a merge node for the exact same reason.

1 Like

Thank you very much. Might be a good idea however i still have the error with the upper path to be executed even when no items are “true” at the first if node.

Hi @JUVOJustin, I am afraid this is currently the expected behaviour for multi-input nodes. They will pull in data from all branches, even if these branches wouldn’t otherwise run.

@jan is working on changing this at feat(core): Changed data processing for multi-input-nodes by janober · Pull Request #4238 · n8n-io/n8n · GitHub, though there is no ETA yet I am afraid. You could give the test Docker image mentioned in the GitHub conversation a go if you’d like to test this first hand before it’s ready.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.