Weird behaviour with IF Node (bug?)

Describe the issue/error/question

I don’t know about you, but shouldn’t this node return true?

It does if I run it from the node, but it does not if I execute the workflow from scratch.

Screenshot of weird behaviour (bug?)

What is the error message (if any)?

Please share the workflow

Share the output returned by the last node

For some reason it returns true if I run from the node (the correct value), but it returns false if I run the workflow from “Execute Workflow”

Information on your n8n setup

  • n8n version: 0.201.0
  • Database you’re using (default: SQLite): Postgres
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm,, desktop app]: K8s

Hey @joeldeteves,

You are not wrong there, I have created an internal dev ticket which we will be tracking as N8N-5395.

1 Like

Glad you were able to reproduce! Hopefully it will be fixed soon. I’ll try to find a workaround in the mean time using the Code node

Just a heads up, this is happening with the Code node as well.

So it doesn’t seem to be releated to the IF node per se, but something else in the workflow that is causing this:

I found a workaround for this bug:

Rather than measuring by Key length, I simply check to see if the key exists at all.

I think this is a more reliable way to deal with the problem of checking to see if the previous node output is empty.

UPDATE: Here is the one-liner version in case anyone needs it (updated the workflow below with both examples):

{{ $json["keyname"] ? true : false }}

Thank you,

I think this is always the case. Getting coding tips for those kinda things as well.(notes while typing code)
It does then actually say it will always return true or false for example.
Not sure 100% why you cannot do length, but it is not a bug.

I think where the bug is is the fact that when you execute directly from the node it returns the correct result, but when you execute from the beginning of the workflow, it returns the wrong result (in spite of the fact that both values show as ‘true’) - that does seem like a bug to me.

However I can confirm my workaround definitely works. I wil probably continue to use the ‘if exists’ method vs the zero-length method.