# Unknown error in Code node

**URL:** <https://community.n8n.io/t/unknown-error-in-code-node/243619>\
**Category:** Questions\
**Tags:** node\
**Created:** [December 31, 2025, 3:34pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619 "2025-12-31T15:34:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![bosman81](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bosman81/32/148892_2.png) [@bosman81](https://community.n8n.io/u/bosman81)\
**Post date:** [December 31, 2025, 3:34pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/1 "2025-12-31T15:34:14Z")

</div>

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!

## Workflow

```auto

```

## Information on your n8n setup

- **n8n version:** 2.1.2
- **Database (default: SQLite):** None
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** Docker
- **Operating system:** Ubuntu

---

<div class="post-metadata">

**Author:** ![achamm](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/achamm/32/143734_2.png) [@achamm](https://community.n8n.io/u/achamm)\
**Post date:** [December 31, 2025, 3:39pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/2 "2025-12-31T15:39:53Z")

</div>

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;`

---

<div class="post-metadata">

**Author:** ![bosman81](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bosman81/32/148892_2.png) [@bosman81](https://community.n8n.io/u/bosman81)\
**Post date:** [December 31, 2025, 3:59pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/3 "2025-12-31T15:59:15Z")

</div>

Changing the first line to use $(‘Inputs’).all() instead of first() returns an empty json output.

```auto
[
  {
    "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](https://docs.n8n.io/code/cookbook/code-node/get-binary-data-buffer/), this is the recommended way. This is what I get when using your suggestion which is incorrect.

```auto
[
  {
    "files": [
      {
        "fileName": "IMG_0075.PNG",
        "mimeType": "image/png",
        "base64Image": "filesystem-v2"
      }
    ]
  }
]

```

---

<div class="post-metadata">

**Author:** ![achamm](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/achamm/32/143734_2.png) [@achamm](https://community.n8n.io/u/achamm)\
**Post date:** [December 31, 2025, 4:03pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/4 "2025-12-31T16:03:24Z")

</div>

I apologize, I’m not the best with JSON.

---

<div class="post-metadata">

**Author:** ![achamm](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/achamm/32/143734_2.png) [@achamm](https://community.n8n.io/u/achamm)\
**Post date:** [December 31, 2025, 4:06pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/5 "2025-12-31T16:06:59Z")

</div>

what about keeping line 1 as the item first, but changing line 14 to `let base64Data = await item.binary[logoKey].getBuffer();`

---

<div class="post-metadata">

**Author:** ![Shraddha\_Singh](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/shraddha_singh/32/148667_2.png) [@Shraddha\_Singh](https://community.n8n.io/u/Shraddha_Singh)\
**Post date:** [December 31, 2025, 4:08pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/6 "2025-12-31T16:08:04Z")

</div>

> [@bosman81](#):
>
> 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!
> 
> ## Workflow
> 
> ```auto
> 
> ```

Change $(‘Inputs’) to $input since your Code node receives data from the directly connected Set Variables node (which passes through the binary data)

const item = $input.first(); // Changed from $(‘Inputs’).first()

if (!item.binary) {  
return [{ json: { files: } }];  
}

const binaryData = item.binary;  
const allFiles = ;

const logoKey = ‘logoPhoto’;  
if (binaryData[logoKey]) {  
let base64Data = await this.helpers.getBinaryDataBuffer(0, logoKey);  
const base64String = base64Data.toString(‘base64’);

```auto
allFiles.push({
    fileName: binaryData[logoKey].fileName,
    mimeType: binaryData[logoKey].mimeType,
    base64Image: base64String,
});

```

}

return [{ json: { files: allFiles } }];

---

<div class="post-metadata">

**Author:** ![bosman81](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bosman81/32/148892_2.png) [@bosman81](https://community.n8n.io/u/bosman81)\
**Post date:** [December 31, 2025, 4:15pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/7 "2025-12-31T16:15:34Z")

</div>

Error  
this.helpers.getBuffer is not a function [line 14]

---

<div class="post-metadata">

**Author:** ![bosman81](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bosman81/32/148892_2.png) [@bosman81](https://community.n8n.io/u/bosman81)\
**Post date:** [December 31, 2025, 4:17pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/8 "2025-12-31T16:17:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![achamm](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/achamm/32/143734_2.png) [@achamm](https://community.n8n.io/u/achamm)\
**Post date:** [December 31, 2025, 4:27pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/9 "2025-12-31T16:27:00Z")

</div>

your set node is off, so it isnt sending any other fields needed. Turn it on, and then you can also try this code.

```auto
const item = $('Inputs').first(); 

if (!item.binary) {
    return [{ json: { files: [] } }];   
}  

const binaryData = item.binary;
const allFiles = [];
const logoKey = 'logoPhoto';

if (binaryData[logoKey]) {
    const base64Data = item.binary[logoKey].data;
    allFiles.push({
        fileName: binaryData[logoKey].fileName,
        mimeType: binaryData[logoKey].mimeType,
        base64Image: base64Data,
    });
}

return [{ json: { files: allFiles } }];

```

---

<div class="post-metadata">

**Author:** ![bosman81](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bosman81/32/148892_2.png) [@bosman81](https://community.n8n.io/u/bosman81)\
**Post date:** [December 31, 2025, 6:40pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/10 "2025-12-31T18:40:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![achamm](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/achamm/32/143734_2.png) [@achamm](https://community.n8n.io/u/achamm)\
**Post date:** [December 31, 2025, 8:05pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/11 "2025-12-31T20:05:16Z")

</div>

Can you use the https node to get the binary from the webhook URL after the IF node? or you can refrence the webhooks binary

---

<div class="post-metadata">

**Author:** ![bosman81](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bosman81/32/148892_2.png) [@bosman81](https://community.n8n.io/u/bosman81)\
**Post date:** [January 1, 2026, 9:33am UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/12 "2026-01-01T09:33:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![achamm](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/achamm/32/143734_2.png) [@achamm](https://community.n8n.io/u/achamm)\
**Post date:** [January 1, 2026, 2:25pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/13 "2026-01-01T14:25:49Z")

</div>

I don’t believe it’s a bug, N8N V2 just changed a lot of things but at least you solved it!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/36532_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [January 8, 2026, 2:26pm UTC](https://community.n8n.io/t/unknown-error-in-code-node/243619/14 "2026-01-08T14:26:40Z")

</div>

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