"[ERROR: Can’t get data for expression]" on Set node variable preview when connected to both ends of If node

I got the same bug with the FTP-Module: “Can’t get data for expression”

Changing the syntax from $(‘Value’) to $node[‘Value’] did work!

Thank you :slight_smile:

Damn! I’m so glad about your reply on this topic.
I ended up having the same problem again on a new workflow and had to search for a solution all over again, because I had forgotten the workaround.

Today is February 23, 2024 and this bug is still alive.

Almost a year of this bug.
@Jon @jan Do you have a ranking ot the longest-living bugs? hahah I bet this one would be a front-runner. Damn little thing. We need an expert exterminator for this one :skull::zap::lady_beetle:

1 Like

Sorry to here that there is still an outstanding issue here.

Honestly I am a little bit confused what is going on here and if they are all the same issues or multiple one. Can somebody please provide a simple workflow with data mocked (either with Code-Node or data pinned) that we can simply execute without external dependencies to see that issue. We will then have a look and make sure it gets fixed asap. Thanks a lot!

Hey @jan ,
I tried to create that workflow for you, but for some reason when I changed enough things in the flow, the bug went away.

I basically disconnected the nodes, created a Set node and then it was working.
So I thought “it’s probably something happening with the original node”.

Connected everything back to the original setup and… bug gone :man_shrugging:
So weird.

What’s even weirder is that this bug has happened to be before, quite a while back, with a different version and different server.

I have no idea how to reproduce it.

1 Like

Thanks a lot for giving it a try.

Is quite possible that the bug simply got fixed in the meantime. If you or anyone else has a good simple workflow please share. Thanks!

Hi @jan ,

I have encountered this bug again, but this time I can’t use first() because I need the other items!

Here’s a rough mock-up for you which seems to cause the (or one of the) errors.

The issue appears to occur after data has been sent through the IF node, and after a subsequent node is positioned which “blocks” the original data. Subsequent nodes then fail to retrieve data from nodes which are located prior to the IF node.

If you remove the Supabase HTTP Request node, the issue goes away.

The Supabase HTTP Request node works fine, because it’s referencing $json (or perhaps because it’s immediately after the IF node?), but the “Consolidate3” code node is referencing the IF node itself, and it can’t do that when it’s behind the Supabase HTTP Request node.

Really hard to explain, but I hope that helps.

@James_Pardoe ,

I have encountered this bug again, but this time I can’t use first() because I need the other items!

You are addressing the node with more than one output. By default the 1st output is used. If you need an item from the 2nd (or subsequent) output, you need to specify that. Please, refer to Output of other nodes | n8n Docs for more details.

If it is only one item in Code node, then the expression could be $('Is the email discarded?').first(1).json, where 1 is the index (zero-based) of the 2nd output.

1 Like

Sorry I don’t fully understand. There isn’t a specific output that I need.

I need it to process all of the items in the same way the rest of n8n does. What am I missing?

The workflow you demonstrated does not imply that. It appears to me that your design (at least the part your shared) is not fulfilling the requirements. If you “need it to process all of the items”, why would “Consolidate3” node refer to IF node if by “all of the items” you mean all the items regardless what output of IF node they come out? In the latter case you can reference “Code” node instead.

If by “all of the items” you mean that “false” output of IF node can have more than one item then you can use the following statement const inputData = $('Is the email discarded?').all(1).map(i => i.json);. Note the function all() instead of first(). You would also need to switch your “Consolidate3” node’s mode to “Run Once for All Items”.

Thanks @ihortom

So if I understand correctly, the issue here is that there are two baskets of items. The first set (Basket A) is the set of items from the pinned output. As soon as the HTTP Request node is run, it outputs a new set of items (Basket B).

So when subsequent nodes are being run ‘per item’, they are seeking data from Basket A, but are being cycled through Basket B, which is why it breaks.

Is that essentially what’s happening?

In which case, to solve this problem, I need a code node that runs once for all items, and then loop through the first set of items within that?

@James_Pardoe , I think you overcomplicate things. It’s rather the design issue than anything else. I would do something like this (visually, adjust the code accordingly).

Thank you!