Both legs executing after IF statment

Hi all,

I am a new n8n user (currently in the trial, 4 days left), and I’m struggling with a conditional (IF) statement not working as expected.

I am processing attachments to Google mails. My workflow starts with an IF statement that decides which leg of the workflow has to handle a message based on the subject.

However, the result I get is that both legs are followed, IE the message is handled by the correct leg, but also by the incorrect leg. So, every message that fits the filter is handled in both a correct and incorrect way.

I expected that only one of the 2 legs will complete, with one of the actions taken (in one case the attachment is written to a folder, in the other a spreadsheet is updated with some information from the email, as well as a link to the attachment).

I have checked the forums, and have found some info on this, but not something that helped me to resolve the problem.

I’ll attach the workflow which should make things clearer.

Thanks in advance for your help
Reinier

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.38.2
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: Fedora Linux

What is the objetive of Merge in both legs?

To bring the binary blob (the attachment) forward so that it can be saved to Google drive with a specific filename that was constructed during previous steps.

From the forums it semed that the binary file is not carried forward through nodes, but with the merge it can be combined with the data from the Edit Fields so that it can be written.

In both cases the attachment is written to disk, but it is stored in different places, with a different name, and in the lower leg the filename is recorded in a Google Sheet.

But you dont need the Merge to get the file from the previous nodes, se this example:

Hi,

I tried removing the merges from the flow, but executing them gives the error below:


This operation expects the node’s input data to contain a binary file ‘attachment_0’, but none was found [item 0]

Ask AI :sparkles:

Make sure that the previous node outputs a binary file

I also tried to refer to attachment_1, as in your example, but got the same error. When I switch the input to the Gmail trigger, and select Binary, it shows the attchment with the name attachment_0, but it doesn’t work, when the Input Data Field Name on the Google Drive node is attachment_0.

This is the error I encountered earlier, and after searching on the forum, I found a suggestion to use the merge, as you can’t refer back to a binary attachment on a previous node.

Is the secret that the Google Drive upload must come directly after the IF node? That will require some reworking of the flow to make it work.

Thanks
Reinier

If you open the IF and do a Test Step, what appear on the left window in the Binary tab?

example:

I get the binary attachment_0 on the Input (left) side, and also on the False Branch (in this case) on the Output (right) side.

I then went back to the Google drive node, and selected the IF node as Input. I can see the attachment_0 under Binary, but still get the same error when I test the Google Drive node.

If I remove the Edit Field node between the IF and the Google Drive node, it works. Unfortunately, then I have the wrong filename for the file, as the Edit Fields builds the filenames.

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