Merge Behavior Not Expected

Describe the problem/error/question

When I use a merge node I am expecting it to wait to receive both inputs in order to provide a merged output, otherwise it is just a passthrough node. I have outlined several scenarios where the merge node behaves differently depending on what input is used below. This inconsistent behavior introduces a lot of room for error when designing complex workflows.

If this is expected behavior I would like to confirm that.

I am attempting to achieve workflows that check for check for truthiness in the response from an HTTP Request Node and pass the data that was input to the HTTP Request node to the next workflow node. Since (at least from what I’ve found so far) there is no way to merge input and output for HTTP Request nodes, I need to use a Merge Node to pass the output from the node prior to the HTTP Request (i.e. the input to the HTTP Request) if the HTTP Request passes my IF statement. I could wire the output of my IF node to Input 1 of my merge node and the output prior to my HTTP Request to Input 2 of the Merge so that the merge is triggered after the IF and the Merge is only configured to pass Input 2, however, in some cases I need to Append the Inputs in which case this will not work.

Observations

  1. If Merge is configured for Append Mode and Input 1 is available, but not Input 2 then the workflow branch will continue.
  1. If Merge is configured for Append Mode and Input 2 is available, but not Input 1 then the workflow branch will not continue.
  1. If Merge is configured for Choose Branch Mode, Output Type “Wait for Both Inputs to Arrive”, and Output “Input 1 Data”, then workflow will continue when Input 1 is available regardless of whether Input 2 is available, despite the Wait for Both Inputs to Arrive.
  1. If Merge is configured for Choose Branch Mode, Output Type “Wait for Both Inputs to Arrive”, and Output “Input 2 Data”, then workflow will not continue when Input 1 is not available regardless of whether Input 2 is available.

What is the error message (if any)?

None

Please share your workflow

See above examples.

Information on your n8n setup

  • n8n version: 0.219.1
  • Database: PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via: Docker
  • Operating system:

Hi @ryanflomenco, I am afraid this is currently expected - the Merge node will expect both inputs to be connected and will try to pull in data from both branches, even if one of them wouldn’t otherwise run. These restrictions can lead to surprises, some of which are hopefully addressed with this upcoming change.

Perhaps you want to try out the n8nio/n8n:PR-4238-workflow-version-2 docker image and see if this works for you (you’ll need to add new Merge nodes from scratch in order to see this)? In your example scenario 2 for example the execution would continue (which it currently does not):

2 Likes

Thanks @MutedJam!

I’ll check out n8nio/n8n:PR-4238-workflow-version-2 and also looking forward to the v1 release end of June.

3 Likes

New version [email protected] got released which includes the GitHub PR 4238.

Summary

I think this broke my flow, where I compare two datasets – now it just disregards input B (and don’t trigger that node) and keeps moving forward with just the input A data.

How do I fix it? I can’t see to find any new options.

Previously the “compare dataset” node got data in input A, pulled data input B, compared, and if different output. The node is set always to output data, and the IF node goes true (which in turn creates an item via API) or false based on whether the output is empty.

EDIT: Never mind. Force refresh in browser a few times and it worked. Very strange behavior.
EDIT2: This had nothing to do with it, I apparently set the workflow to legacy order first.

Sounds like expected behavior. Please check out our migration guide:

It will only behave that way if the workflow is configured accordingly via the workflow settings (is the default for all newly created ones):

1 Like

Makes sense, since I just set up a new n8n instance and imported a workflow.

1 Like

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