Issues with Logical OR and Ternary Expressions

Logical || and Ternary Expressions not working.

ERROR: Bad request - please check your parameters

Please share your workflow

Share the output returned by the last node

ERROR: Bad request - please check your parameters

More info

I just upgraded from 0.226.0 → 1.4.1 and now have a few breaking issues to work out.

First off the list.
My expressions are failing. In the past I would have nodes which may or may not fire, like in the snippet above. There is a cron which starts this flow, and then there is the webhook triggered loop which keeps it going if the work was not finished.

the page tracks this. In the past I would use a logical || in the expression however now that produces this error.
,
{{$node[“Webhook”].json[“body”][“page”] || 1}}
,
ERROR: no data, execute “Webhook” node first

So i tried switching to a Ternary operator.

{{$node[“Webhook”].json[“body”][“page”] ? $node[“Webhook”].json[“body”][“page”] : 1}}

Which results in the same error.

Now… I would keep upgrading all the way up to current but looking at the change log, 1.4.1 looked like a good stopping point.

Information on your n8n setup

  • **n8n version: 1.4.1
  • Database (default: Postgress):
  • **n8n EXECUTIONS_PROCESS setting :**Main
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):Cloudron Docker
  • Operating system: Ubuntu

Hi @roofboard, I am sorry you’re having trouble.

Expressions referencing non-existing data are now leading to the full workflow execution failing. This is an intentional change announced in n8n v1.0 migration guide | n8n Docs.

For your example, perhaps you want to use a Set node before your HTTP Request node? You can configure it to continue even when hitting errors like so:

image

In your HTTP Request node you can then read from this Set node (which will always run) instead of the Webhook node which might not run. Like so:

1 Like

Wow this is a huge degradation of service. I wish i never upgraded. It breaks half the fallbacks and error handling that i have built into my workflows.

It is important to note that the node does exist, it simply has not run for one of potentially many reasons.
That could be multiple triggers or as a method of discerning what happened previously in the workflow.

for example

A →
IF A. do C, IF B do D
B->

Node A and B exist, but the workflow is failing just because B has not fired.

hi @roofboard

It is not degradation, it is wrong architecture. You shouldn’t rely on data from nodes that won’t be executed.

So in your case, you can use a relative path to get it working:
{{ $json.body?.page || 1 }}

1 Like

I am not relying on data from nodes which have been executed, I am just checking to see if they have been executed.

it would have to be
{{ $node(‘nodeName’).json.body?.page || 1 }}
or would {{ $node(‘nodeName’)?.json.body?.page || 1 }} work?

Because often times I reach clear across the workflow to check if there is a piece of data.

Would that work?

That one is correct. But only if that node will output something. A relative reference (specifying $json instead of $node…) can trick the n8n to ignore whatever it has before, as the node will receive some input in any case. But that thing won’t work with node reference ($node)

2 Likes