I am getting an “Unknown Error” from the code node in my workflow. The error is very vague
Problem in node ‘Extract LogoPhoto: Unknown error
However, I was able to narrow it down to a few symptoms:
1- The error goes away if I remove the Set Variables node, i.e. the code node is directly connected to the Inputs webhook
2- The error goes away if I change the first line of the code node from
const item = $(‘Inputs’).first();
To
const item = $(‘Inputs’).all();
However, the output is wrong
3- The error goes away if i remove the await line in the code node and the output of the code node is correct with const item = $(‘Inputs’).first();
I have no way of debugging this further and can use some help!
As you said, I would change the first line to const item = $(‘Inputs’).first();I would also change line 14 from what you have it as to const base64Data = item.binary[logoKey].data;
Changing the first line to use $(‘Inputs’).all() instead of first() returns an empty json output.
[
{
"files": []
}
]
Changing line 14 to use data instead of getBinaryDataBuffer() no longer works in version 2.X (used to work in older n8n versions). And according to n8n documentation, this is the recommended way. This is what I get when using your suggestion which is incorrect.
My code node is not getting input directly from the previous node. There are nodes in the middle, the Set Variables node shown is the node in the middle in this workflow, so $input will not work
Good catch. Turning “Include Other Input Fields” on helps solve the problem with this mini example. However, in my real workflow, there are several other nodes in the middle, like HTTP node, an IF node, a data table node. None of those nodes have an option to let the binary file pass through.
unfortunately that didn’t work. I ended up moving nodes around to get around this error. I honestly think there is an n8n bug somewhere in the new version (2.X) because this workflow has been working just fine for months with n8n 1.X