When using Switch node, we see output on multiple gates (2) instead of single gate (as logically expected). The unexpected output gate is not the fallback/default gate
What is the error message (if any)?
none
Please share your workflow
Share the output returned by the last node
Information on your n8n setup
n8n version:: 0.228.2
Database (default: SQLite): SQLite
n8n EXECUTIONS_PROCESS setting (default: own, main): main
Running n8n via (Docker, npm, n8n cloud, desktop app): via Docker compose
for example when this is the input item into the Switch node
the output gates 0 and 1 are selected. Output gate 0 has NULL item, Output gate 1 has original input item forwarded
Hi @sl-tobe, thanks so much for sharing your example here. When testing your example I can see that one of the items passed on by the Switch node is an empty item.
This would have been generated by the “Always Output Data” option of your Switch node:
This option will prevent your workflow from stopping on the node. It does this by sending an empty item to the first output of a node (if there is no other item on that output).
So to avoid having multiple items coming from your Switch you would want to disable this setting. Afterwards only 1 output is used in your example:
Hi, thanks for your reply
What is the logic behind this when another gate is really selected by the condition anyway?
Why does it select first gate and not gate 3 or even 4?
I would assume that whenever NO condition is met, it output empty item to gate 0 if this selector (always output) is enabled.
thanks
Stefan
Hi @sl-tobe, this option is not node-specific. Since most nodes only have one output, it would use the first (and often only) output to pass on the empty item.