Multiple paths into an IF or SWITCH node gives wrong output

When I have two input paths to either an If or Switch node (one from a webhook and one from execute node - permits the workflow to be called tw different ways) both the If and Switch go down the false path when I compare an input string to a fixed value. If I remove either of the inputs, it works perfectly.

Per execution, only one input will be used, either executed via webhook, or run from a parent workflow. So why does a seconf input break it?

What am I missing here?

Please share your workflow

(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: Latest
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: AWS

Hi @Jshroads, welcome to the community. I am very sorry you’re having trouble.

I just gave this a go on my side and am seeing the following result when starting the workflow using the manual trigger node:

When sending a webhook like below the workflow also continues on the false branch of the IF node:

curl --request POST \
  --url https://mutedjam.app.n8n.cloud/webhook-test/api/revio/customers \
  --header 'Content-Type: application/json' \
  --data '{
	"module": "foo",
	"object": "bar",
	"item": 123,
	"method": "qux"
}'

This is expected since my method value does not contain get as defined in the IF node:

If I were to send a webhook using get in the method field the execution would continue on the true branch instead:

curl --request POST \
  --url https://mutedjam.app.n8n.cloud/webhook-test/api/revio/customers \
  --header 'Content-Type: application/json' \
  --data '{
	"module": "foo",
	"object": "bar",
	"item": 123,
	"method": "get"
}'

So from over here things seem to work as they should. Can you confirm what exactly breaks for you (ideally share a screenshot of any error you are seeing) and which behaviour exactly you’d expect in each of the scenarios (manual, webhook with method!=get, webhook with method=get)?

Thank you for the in depth reply and insight :grinning:

Let me digest it and see if I can tease the IF statement into going down just one path.

I’m trying to build some n8n nodes that mimic objects in the OOP sense. To keep the URLs very simple, I will pass the object name, method and data in the body of the request (when invoked by a webhook) and if the object is just executed within a workflow, i will make the parameters available in the input. My goal is that an object will behave the same regardless of how invoked, and it has the benefit of being easier to test.

1 Like

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