Bug Report: Binary Data from Code Node Cannot Be Sent via HTTP Request Node

:bug: Bug Report: Binary Data from Code Node Cannot Be Sent via HTTP Request Node

Tags: bug critical database-mode queue-mode http-request binary-data


Environment

  • n8n version: 2.6.4 (Self Hosted)
  • Binary data mode: database
  • Execution mode: queue (with Redis)
  • Database: PostgreSQL
  • Node.js version: 20.19.6

Problem Description

Binary data created in a Code node cannot be sent through an HTTP Request node when binaryDataMode=database. The HTTP Request node fails with the error:

"data should be a string, Buffer or Uint8Array"

This issue does not occur when binary data comes from other sources (Webhook, Download File, etc.) — only when created programmatically in a Code node.


Reproduction Steps

Minimal Test Workflow:

  1. Manual Trigger

  2. Code Node (Run Once for All Items):

const fakePdfContent = '%PDF-1.4\n...'; // Minimal valid PDF

return [{
  json: { testName: 'Binary from Code Node' },
  binary: {
    data: {
      data: Buffer.from(fakePdfContent, 'utf-8').toString('base64'),
      mimeType: 'application/pdf',
      fileName: 'test.pdf'
    }
  }
}];
  1. HTTP Request Node:

    • Method: POST
    • URL: https://httpbin.org/post
    • Body Content Type: Multipart-Form Data
    • Body Parameter:
      • Type: n8n Binary File
      • Name: file
      • Input Data Field Name: data
  2. Execute workflow:cross_mark: Error occurs


Expected Behavior

The HTTP Request node should accept and send binary data created in a Code node, just like it does for binaries from other sources.


Actual Behavior

Error:

{
  "errorMessage": "data should be a string, Buffer or Uint8Array",
  "n8nDetails": {
    "nodeName": "HTTP Request",
    "nodeType": "n8n-nodes-base.httpRequest",
    "nodeVersion": 4.4,
    "n8nVersion": "2.6.4 (Self Hosted)",
    "binaryDataMode": "database"
  }
}

Stack trace: NodeApiError at HttpRequestV3.node.ts:864


Impact

:warning: Critical workflows are blocked:

  • Cannot merge multiple PDFs using Gotenberg API
  • Cannot process/transform binaries in Code then upload via HTTP
  • Forces complex workarounds using this.helpers.request() in Code nodes

Production workflows affected:

  • PDF merging workflows
  • Document processing pipelines
  • Any workflow requiring: Code node manipulation → HTTP upload

Workaround Found

Using this.helpers.request() inside the Code node instead of the HTTP Request node works:

const response = await this.helpers.request({
  method: 'POST',
  uri: 'https://api.example.com/upload',
  formData: {
    file: dataUrl  // Works with data URLs
  }
});

:warning: However, this workaround:

  • Only works for simple cases (single file, data URL)
  • :cross_mark: Fails for complex multipart (multiple files) → Returns 403 from strict APIs
  • Requires rewriting all HTTP Request nodes as Code
  • Loses HTTP Request node’s UI benefits

Related Issues

This appears related to known filesystem mode issues, but occurs even in database mode:

  • Issue #25065 (Binary file rename errors)
  • Issue #25066 (Race conditions with temp folders)
  • Issue #14271 (Binary data not visible)

Question for Developers

  1. Is this a known bug in 2.6.4?
  2. Has it been fixed in 2.7+ / 2.8+ / 2.9.0?
  3. Is there a recommended approach for Code→HTTP workflows until fixed?

Additional Context

We’ve tested extensively and confirmed:

Scenario Result
Webhook → HTTP Request with binary :white_check_mark: Works
Download File → HTTP Request with binary :white_check_mark: Works
Code Node → HTTP Request with binary :cross_mark: Fails consistently

The bug appears to be in how the HTTP Request node handles binary references when binaryDataMode=database and the binary was created in Code.


Would appreciate any guidance or timeline for a fix. Thank you!

hello @maxime.lacoste

You shouldn’t access the Buffer directly; you will need to access the binary via the this.helpers.getBinaryDataBuffer() method, as stated in the docs:
Get the binary data buffer | n8n Docs

But better to use native binary nodes like Convert to File or Extract From File.

The issue here is actually how you’re constructing the binary object in the Code node, not the HTTP Request node itself. When you return binary data from Code you need to use await this.helpers.prepareBinaryData() which properly registers it with n8n’s binary storage system, otherwise you’re just creating a raw object that looks like binary data but isn’t actually managed by n8n. The docs on that are here: https://docs.n8n.io/code/cookbook/builtin/output-binary-data/

Claude AI & I :sweat_smile: would like to thank you both for your helpful suggestions. I really appreciate the guidance.

I tested all your approaches:

  1. Using getBinaryDataBuffer() → Infinite loop, workflow never completes
  2. Using prepareBinaryData() → Gotenberg returns 403
  3. Native HTTP Request after Code node → Same “data should be a string, Buffer or Uint8Array” error
  4. Convert to File / Extract From File → Not suitable for dynamic number of files

After extensive testing, I’ve confirmed this is a bug in n8n 2.6.4 with binaryDataMode=database.

Any binary data that passes through a Code node becomes unusable by the HTTP Request node, even when using the official helper methods.

Simple reproduction:

  • Manual Trigger → Code node (create binary) → HTTP Request (send as multipart)
  • Error: “data should be a string, Buffer or Uint8Array”

Questions:

  1. Is this a known issue in 2.6.4?
  2. Has it been fixed in 2.7+/2.8+/2.9.0?
  3. Should I open a GitHub issue?

Environment: n8n 2.6.4 (Self Hosted), database mode, queue mode with Redis, PostgreSQL

Thank you again for teaching me the proper n8n methods!

Why are you trying to generate binary data via the code node? That’s a very rare case to use the Code node.

Better to generate a JSON and then convert it to binary with the Convert node.

There are no issues with dynamic files; you need to correctly process them.

Thank you for the suggestion! However, I should clarify:

My Code node doesn’t generate binaries - it only groups and renames existing binaries that come from a Download Files node. The binaries are already properly registered by n8n.

The issue is that ANY binary that passes through a Code node (even just for grouping/renaming) becomes unusable by the HTTP Request node in queue mode with database binary storage.

I found that this is actually a confirmed bug: GitHub issue #25567 describes exactly this problem. It’s a regression in queue mode that affects HTTP Request + multipart/form-data + binary files, regardless of how the binaries were created.

A fix is currently in progress (PR #25807).

In the meantime, I’m using the 5 separate HTTP Request nodes workaround, which will work once the bug is fixed.

Do you have experience with Convert to File for processing multiple dynamic binaries in this specific queue mode + database context?

The issue, which you have specified, is related to the Docker image manipulations from Cloudron.
multipart/form-data Unable to calculate form data length · Issue #26606 · n8n-io/n8n

Can’t say that the Code node somehow modifies the binary data. Can you share the use case?

Not using Cloudron. n8n is deployed on Scalingo (French PaaS) using their official one-click n8n repository, which uses the standard n8n Docker image. Issue #26606 does not apply. Symptoms match #25567 exactly : queue mode + Redis + PostgreSQL binary storage, item.binary is null in Code node, infinite loop when HTTP Request tries to read binaries after any intermediate node.