Function Node Error After Updating n8n

I have been using a Function node immediately preceding an Email node to prepare a renamed file as an attachment. After updating n8n, I am getting an “ERROR: item is not defined [Line 2]” result from that node.

Information on your n8n setup

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

I do not know Javascript very well at all so any help would be appreciated getting around this issue. Thanks!

Hey @chadgriff1,

Welcome to the community :tada:

It might be worth trying the code node and updating the code to see fi that helps. That being said the Set node seems to have an expression for the Keep Only Set option which probably doesn’t need to be there, Would you be able to share a screenshot of the output of the Set node as well?

Here is a screenshot of the Set Node. I am just appending a Month Year identifier to the end of the filename. FYI…I removed the Keep Only Set option and re-tested. I still received the error associated with the Function Node. I have tested using the Code Node several times but my lack of understanding of which method to use and how to configure it is limiting my ability to get this working.

Hey @chadgriff1,

So looking at that there is no binary data coming from the Set node so item.binary doesn’t exist, I would say as you have a function node there already it might be worth dropping the set node and just setting the filename directly in the function node.

Is there any way we can see the full workflow to understand it a bit more?

Hey @Jon ,

Thanks for your continued help on this. As a reminder, that was working prior to the update I recently peformed on It had been a decent amount of time since I last updated n8n so a change could have occurred quite awhile ago which changed the behavior of the Function Node.

Hey @chadgriff1,

It is possible that we changed something there, We do releases weekly and sometimes things change that get missed. Looking at this one I can see the problem, It looks like the Set node is not getting the data from the Report Request.

Does this work…

Really strange. I am actually pretty sure that it is nothing we changed. That code should always have failed.

Are you saying the workflow worked exactly like that? Because that would be very surprising. Or do you say you had a workflow like that before and there it worked. That would be possible. Because it looks for me like you copied the code from a Function Item Node (where it would work) into a Function Node (where it should not work).

@Jon ,

The solution you provided works. Thank you very much for your help.

@jan ,

I was using a Function Node from the very beginning (I believe I cut and pasted an example from a solution I found in this Community) when I first set it up. After the update is when the error started occurring.

@jan ,

I have several of these workflows built in the same fashion. Based on the discussion with @Jon today I went to one of the others and tested…it also failed with the same error code on the Function node. However, I went to look at the SET node and realized the binary file was not passing through. I turned off the Keep Only Set feature that was not needed and the workflow started working again (i.e. the binary file passed through the SET node). So just wanted to mention this for your awareness / understanding.

As I always try to ensure that we do not break anything unintentionally did I now do some testing to see where it could have broke. Did run in the following n8n versions: 0.111.0, 0.161.0, 0.171.1, 0.187.2, 0.193.5, 0.201.0
in all of them it throws the same error: ERROR: item is not defined

So can still not understand how that could have ever worked unless the code was in a Function Item node where it would work in every version.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.