[BUG] "IF Node" potential bug

I think there might be a bug in the “IF” node. Let me explain and let me know what you think.

I have 121 items being processed.

The IF node is checking to see if the time to close exists

image

When you run the node manually it splits the results correctly,
image

however, if you execute the entire flow, the node gets it wrong.

Can someone look into this please?

Hey @RedPacketSec, thanks so much for reporting this! Could you please provide a workflow using which this can be reproduced and confirm which version of n8n you’re currently using? Thx!

image

i can share the workflow privately, but you would need to use your own dummy data.

Hi @RedPacketSec, can you simply provide a public workflow including dummy data? This would make things considerably easier. Thanks so much!

yeah it makes it much harder for me, as there is a lots of stuff i need to do to sanitise this.

i’ll see what i can do

1 Like

and save this as test2.json

{
	"records": [
{
  "opened_at": "2022-02-09 08:01:12",
  "closed_at": "2022-04-05 09:57:12"
},{
  "opened_at": "2022-04-20 13:34:27",
  "closed_at": "2022-05-04 13:05:03"
},{
  "opened_at": "2022-05-13 07:13:26",
  "closed_at": ""
},{
  "opened_at": "2022-07-06 08:01:24",
  "closed_at": ""
},{
  "opened_at": "2022-04-20 10:29:55",
  "closed_at": ""
},{
  "opened_at": "2022-01-17 14:58:37",
  "closed_at": "2022-01-19 20:37:05"
},{
  "opened_at": "2022-01-12 08:17:52",
  "closed_at": "2022-03-02 10:09:32"
},{
  "opened_at": "2022-04-22 08:40:45",
  "closed_at": "2022-04-22 08:57:18"
},{
  "opened_at": "2022-08-03 13:57:41",
  "closed_at": "2022-08-05 16:13:06"
},{
  "opened_at": "2022-01-21 13:30:08",
  "closed_at": "2022-02-03 12:13:16"
},{
  "opened_at": "2022-02-15 08:16:45",
  "closed_at": "2022-04-05 09:55:33"
},{
  "opened_at": "2022-08-11 14:36:11",
  "closed_at": ""
},{
  "opened_at": "2022-03-08 08:10:25",
  "closed_at": "2022-04-04 16:57:24"
},{
  "opened_at": "2022-02-09 07:56:53",
  "closed_at": "2022-08-08 10:55:42"
},{
  "opened_at": "2022-03-21 13:23:36",
  "closed_at": ""
},{
  "opened_at": "2022-02-22 14:02:06",
  "closed_at": "2022-03-02 14:23:08"
},{
  "opened_at": "2022-05-24 13:19:14",
  "closed_at": "2022-05-24 14:47:49"
},{
  "opened_at": "2022-03-21 12:58:32",
  "closed_at": "2022-03-31 09:15:44"
},{
  "opened_at": "2022-03-08 12:39:00",
  "closed_at": ""
},{
  "opened_at": "2022-02-21 10:47:31",
  "closed_at": "2022-06-07 10:31:48"
},{
  "opened_at": "2022-03-09 11:42:41",
  "closed_at": "2022-05-30 09:10:40"
},{
  "opened_at": "2022-04-19 07:33:48",
  "closed_at": "2022-04-20 07:38:13"
},{
  "opened_at": "2022-01-11 22:08:44",
  "closed_at": "2022-01-12 08:33:58"
},{
  "opened_at": "2022-03-25 08:11:00",
  "closed_at": "2022-03-25 15:03:50"
},{
  "opened_at": "2022-04-21 06:20:07",
  "closed_at": "2022-05-04 12:10:48"
},{
  "opened_at": "2022-02-22 10:32:04",
  "closed_at": "2022-04-05 09:52:16"
},{
  "opened_at": "2022-05-20 06:39:28",
  "closed_at": "2022-05-23 08:43:09"
},{
  "opened_at": "2022-08-19 08:51:12",
  "closed_at": "2022-08-19 14:59:49"
},{
  "opened_at": "2022-02-16 22:44:11",
  "closed_at": "2022-03-30 10:42:31"
},{
  "opened_at": "2022-02-02 10:06:28",
  "closed_at": "2022-04-20 12:59:43"
},{
  "opened_at": "2022-04-19 11:35:36",
  "closed_at": "2022-04-20 07:34:38"
},{
  "opened_at": "2022-02-23 12:36:52",
  "closed_at": "2022-02-24 17:27:45"
},{
  "opened_at": "2022-06-21 08:54:03",
  "closed_at": "2022-07-01 08:55:03"
},{
  "opened_at": "2022-04-27 08:47:30",
  "closed_at": "2022-04-28 07:56:49"
},{
  "opened_at": "2022-07-06 06:23:01",
  "closed_at": "2022-08-15 20:23:12"
},{
  "opened_at": "2022-07-18 14:12:46",
  "closed_at": "2022-08-19 08:33:27"
},{
  "opened_at": "2022-07-19 11:59:06",
  "closed_at": "2022-08-04 17:01:52"
},{
  "opened_at": "2022-02-21 13:34:36",
  "closed_at": "2022-05-05 16:09:47"
},{
  "opened_at": "2022-02-11 08:57:42",
  "closed_at": "2022-04-05 08:35:17"
},{
  "opened_at": "2022-07-04 07:23:59",
  "closed_at": "2022-07-04 08:31:03"
},{
  "opened_at": "2022-01-31 08:01:16",
  "closed_at": ""
},{
  "opened_at": "2022-04-29 13:41:59",
  "closed_at": "2022-05-25 10:42:15"
},{
  "opened_at": "2022-02-01 12:37:42",
  "closed_at": "2022-02-02 11:36:40"
},{
  "opened_at": "2022-01-12 08:01:51",
  "closed_at": "2022-03-04 10:47:57"
},{
  "opened_at": "2022-02-11 08:54:55",
  "closed_at": "2022-04-04 09:51:59"
},{
  "opened_at": "2022-02-11 08:47:52",
  "closed_at": "2022-03-17 09:47:42"
},{
  "opened_at": "2022-04-21 06:22:59",
  "closed_at": ""
},{
  "opened_at": "2022-04-20 10:36:43",
  "closed_at": "2022-04-21 09:20:44"
},{
  "opened_at": "2022-05-12 06:44:27",
  "closed_at": "2022-05-23 10:15:41"
},{
  "opened_at": "2022-04-19 07:29:18",
  "closed_at": ""
},{
  "opened_at": "2022-08-11 14:59:20",
  "closed_at": ""
},{
  "opened_at": "2022-01-17 14:12:59",
  "closed_at": "2022-01-19 20:36:06"
},{
  "opened_at": "2022-05-19 07:21:25",
  "closed_at": "2022-07-04 13:59:00"
},{
  "opened_at": "2022-02-11 09:27:38",
  "closed_at": "2022-02-17 12:25:10"
},{
  "opened_at": "2022-07-18 07:07:07",
  "closed_at": "2022-08-10 10:59:49"
},{
  "opened_at": "2022-07-20 09:02:58",
  "closed_at": ""
},{
  "opened_at": "2022-03-25 08:07:53",
  "closed_at": "2022-03-25 14:58:58"
},{
  "opened_at": "2022-07-04 07:34:07",
  "closed_at": "2022-07-04 08:34:18"
},{
  "opened_at": "2022-02-02 10:54:29",
  "closed_at": ""
},{
  "opened_at": "2022-05-10 06:48:15",
  "closed_at": "2022-07-04 14:12:49"
},{
  "opened_at": "2022-04-19 11:43:32",
  "closed_at": "2022-04-20 07:31:05"
},{
  "opened_at": "2022-03-18 10:57:33",
  "closed_at": "2022-05-25 10:44:41"
},{
  "opened_at": "2022-03-07 07:15:13",
  "closed_at": "2022-05-05 16:10:13"
},{
  "opened_at": "2022-04-22 08:50:01",
  "closed_at": "2022-05-06 07:26:15"
},{
  "opened_at": "2022-06-29 07:13:42",
  "closed_at": ""
},{
  "opened_at": "2022-03-21 14:30:53",
  "closed_at": "2022-06-07 11:20:10"
},{
  "opened_at": "2022-07-07 07:15:57",
  "closed_at": ""
},{
  "opened_at": "2022-08-10 09:25:25",
  "closed_at": "2022-08-11 15:42:21"
},{
  "opened_at": "2022-02-08 10:51:52",
  "closed_at": "2022-06-15 15:20:03"
},{
  "opened_at": "2022-03-18 16:59:01",
  "closed_at": "2022-03-31 09:52:33"
},{
  "opened_at": "2022-01-18 07:34:57",
  "closed_at": "2022-03-04 10:48:59"
},{
  "opened_at": "2022-03-25 08:03:18",
  "closed_at": "2022-03-25 14:56:02"
},{
  "opened_at": "2022-01-12 07:58:09",
  "closed_at": "2022-03-02 10:07:02"
},{
  "opened_at": "2022-03-31 07:46:26",
  "closed_at": "2022-04-07 09:35:56"
},{
  "opened_at": "2022-05-17 05:38:46",
  "closed_at": "2022-07-04 14:05:28"
},{
  "opened_at": "2022-02-23 12:27:41",
  "closed_at": "2022-02-24 17:21:47"
},{
  "opened_at": "2022-08-16 13:55:48",
  "closed_at": ""
},{
  "opened_at": "2022-01-11 08:59:34",
  "closed_at": "2022-01-14 16:51:00"
},{
  "opened_at": "2022-06-08 07:19:52",
  "closed_at": ""
},{
  "opened_at": "2022-04-01 05:59:01",
  "closed_at": ""
},{
  "opened_at": "2022-03-25 08:09:34",
  "closed_at": "2022-05-05 16:04:58"
},{
  "opened_at": "2022-04-27 08:47:28",
  "closed_at": "2022-04-28 07:56:30"
},{
  "opened_at": "2022-03-25 08:13:44",
  "closed_at": "2022-04-05 10:02:35"
},{
  "opened_at": "2022-04-05 08:44:01",
  "closed_at": "2022-04-19 10:13:50"
},{
  "opened_at": "2022-03-22 07:32:03",
  "closed_at": "2022-03-28 07:12:10"
},{
  "opened_at": "2022-08-09 12:59:31",
  "closed_at": "2022-08-09 13:22:24"
},{
  "opened_at": "2022-05-30 12:08:44",
  "closed_at": ""
},{
  "opened_at": "2022-01-10 08:50:02",
  "closed_at": "2022-01-10 10:18:29"
},{
  "opened_at": "2022-08-08 06:57:25",
  "closed_at": "2022-08-12 08:28:53"
},{
  "opened_at": "2022-07-14 15:02:07",
  "closed_at": ""
},{
  "opened_at": "2022-08-04 11:49:13",
  "closed_at": ""
},{
  "opened_at": "2022-05-30 05:54:27",
  "closed_at": "2022-06-06 14:07:17"
},{
  "opened_at": "2022-01-27 12:12:19",
  "closed_at": ""
},{
  "opened_at": "2022-05-27 06:24:07",
  "closed_at": "2022-06-20 10:06:57"
},{
  "opened_at": "2022-01-11 22:04:15",
  "closed_at": "2022-02-07 10:38:26"
},{
  "opened_at": "2022-04-14 12:55:04",
  "closed_at": "2022-04-19 09:52:21"
},{
  "opened_at": "2022-02-01 11:50:30",
  "closed_at": "2022-02-08 12:25:38"
},{
  "opened_at": "2022-07-06 11:30:09",
  "closed_at": ""
},{
  "opened_at": "2022-04-14 13:01:21",
  "closed_at": "2022-05-05 16:11:02"
},{
  "opened_at": "2022-05-04 13:08:37",
  "closed_at": "2022-06-22 06:13:57"
},{
  "opened_at": "2022-03-28 06:52:38",
  "closed_at": "2022-04-05 10:20:37"
},{
  "opened_at": "2022-01-11 13:01:49",
  "closed_at": "2022-03-30 13:05:06"
},{
  "opened_at": "2022-03-08 12:25:35",
  "closed_at": ""
},{
  "opened_at": "2022-08-18 08:15:03",
  "closed_at": ""
},{
  "opened_at": "2022-06-15 07:09:30",
  "closed_at": "2022-07-27 12:08:05"
},{
  "opened_at": "2022-01-10 08:52:39",
  "closed_at": "2022-01-10 10:22:41"
},{
  "opened_at": "2022-01-28 13:30:24",
  "closed_at": "2022-01-31 14:30:12"
},{
  "opened_at": "2022-05-11 06:41:49",
  "closed_at": ""
},{
  "opened_at": "2022-08-19 09:46:41",
  "closed_at": ""
},{
  "opened_at": "2022-07-04 12:12:26",
  "closed_at": "2022-07-22 09:36:34"
},{
  "opened_at": "2022-05-12 09:40:14",
  "closed_at": "2022-05-25 10:09:33"
},{
  "opened_at": "2022-02-11 08:40:06",
  "closed_at": "2022-04-04 09:50:56"
},{
  "opened_at": "2022-02-21 12:44:48",
  "closed_at": "2022-02-22 09:26:55"
},{
  "opened_at": "2022-08-15 07:20:44",
  "closed_at": "2022-08-19 08:18:33"
},{
  "opened_at": "2022-07-07 07:10:55",
  "closed_at": "2022-07-14 13:18:41"
},{
  "opened_at": "2022-01-14 14:39:49",
  "closed_at": "2022-04-05 09:48:01"
},{
  "opened_at": "2022-03-25 08:06:02",
  "closed_at": "2022-03-25 14:57:43"
},{
  "opened_at": "2022-07-27 14:37:04",
  "closed_at": ""
},{
  "opened_at": "2022-07-19 10:52:48",
  "closed_at": ""
},{
  "opened_at": "2022-04-20 10:33:56",
  "closed_at": "2022-05-05 16:10:37"
},{
  "opened_at": "2022-08-10 07:30:29",
  "closed_at": "2022-08-15 20:03:49"
},{
  "opened_at": "2022-05-05 06:33:38",
  "closed_at": "2022-07-04 14:17:45"
},{
  "opened_at": "2022-08-18 09:50:48",
  "closed_at": "2022-08-22 12:28:00"
}
]
}
1 Like

Thanks so much, I can now reproduce the problem! I am not sure what causes this behaviour though, so will add this to our internal bug tracker for a closer look by the engineering team.

1 Like

Yes i think definetely it is a bug with IF node or Merge node output.

The second and the third is the same json output produced by merge node passing it to a function node and it shows that it is working.

1 Like

Yeah, I agree. I’m also caught by surprise by this behavior. Let’s see what the experts find out :crossed_fingers:

1 Like

im wondering if as a work around i can use the switch node?

I think the problem might be related to the string conversion here. Your time_to_close field has a number (such as 55) or JS null, but you’re using a string-based condition in the IF node.

So my suggestion would be to consider a number condition like {{$json["0"]["json"]["time_to_close"]}} larger 0 if that works for you. This seemed to work fine for both manual workflow and node executions. Like so:

even if i choose number instead of string, i get the same result

i cant use 0 it has to be empty or not as the options

Hey @RedPacketSec,

In the merge check the value of the time_to_close before returning it and set it to an empty string or null and it should work.

So something like…

time_to_close: diffDays ? diffDays : null

@Jon the IF node has definitely a bug although right?

Yeah, it is where we convert some data on the backend but not the front end. In this case the value ends up being NaN in the background but null when ran from the UI.

We have some ideas on how to fix this already which is always nice.

3 Likes

image

@RedPacketSec After Merge Node create a Function Node with the code

items = items;

return items;

Then the IF Node will work normally without changing anything from the first post you made.

3 Likes

i can confirm this worked

I now just wonder if any of my older flows are suffering from this one too…