Skip to content

fix: n8n 2.0 compatibility - binary data access and Accept headers#24

Merged
jaseemjaskp merged 1 commit intomainfrom
fix/n8n-2.0-compatibility
Dec 24, 2025
Merged

fix: n8n 2.0 compatibility - binary data access and Accept headers#24
jaseemjaskp merged 1 commit intomainfrom
fix/n8n-2.0-compatibility

Conversation

@Deepak-Kesavan
Copy link
Collaborator

@Deepak-Kesavan Deepak-Kesavan commented Dec 23, 2025

🐛 Problem

n8n 2.0 introduced breaking changes that caused errors in our custom nodes:

  • ❌ HTTP 406 errors in Unstract nodes
  • ❌ UTF-8 encoding errors in LLMWhisperer
  • ❌ Binary file uploads failing

🔧 Root Causes

1. Binary Data Access Changed

In n8n 2.0, binary data is no longer stored in-memory. The old approach of accessing binaryData.data and converting from base64 is deprecated.

Before (❌ Broken):

const binaryData = items[i].binary![fileContents];
const fileBuffer = Buffer.from(binaryData.data, 'base64');

After (✅ Fixed):

const fileBuffer = await this.helpers.getBinaryDataBuffer(i, fileContents);

2. Accept Header Auto-Generation

n8n 2.0 automatically adds Accept: application/json,text/*;q=0.99 which some APIs reject. Unstract/LLMWhisperer APIs require exactly Accept: application/json.

Fix: Explicitly set Accept: application/json in headers to override the default.

✅ Changes Made

Binary Data Access (3 nodes)

  • LlmWhisperer.node.ts - Updated to use getBinaryDataBuffer()
  • Unstract.node.ts - Updated to use getBinaryDataBuffer()
  • UnstractHitlPush.node.ts - Updated to use getBinaryDataBuffer()

Accept Headers (8 locations)

  • LLMWhisperer: POST request + status check + retrieve request
  • Unstract: POST request + status check
  • UnstractHitlFetch: GET request
  • UnstractHitlPush: POST request + status check

🧪 Testing

✅ Tested on n8n 2.0
✅ All nodes successfully process binary file uploads
✅ No HTTP 406 errors
✅ No UTF-8 encoding errors

📚 References

📝 Files Changed

  • nodes/LlmWhisperer/LlmWhisperer.node.ts
  • nodes/Unstract/Unstract.node.ts
  • nodes/UnstractHitlFetch/UnstractHitlFetch.node.ts
  • nodes/UnstractHitlPush/UnstractHitlPush.node.ts

## Breaking Changes Fixed

### 1. Binary Data Access
- Replaced deprecated `Buffer.from(binaryData.data, 'base64')` with `helpers.getBinaryDataBuffer()`
- In n8n 2.0, binary data is stored in filesystem/database, not in-memory
- The `.data` property no longer contains the base64 string

### 2. Accept Headers
- Added explicit `Accept: application/json` headers to all HTTP requests
- n8n 2.0 auto-adds `Accept: application/json,text/*;q=0.99`
- Unstract/LLMWhisperer APIs require exactly `application/json`

## Issues Resolved
- ✅ HTTP 406 errors in Unstract nodes
- ✅ UTF-8 encoding errors in LLMWhisperer
- ✅ "Cannot read properties of undefined (reading 'id')" error
- ✅ Binary data access for all file upload operations

## Nodes Updated
- **LLMWhisperer**: Binary data access + 3 Accept headers (POST, status, retrieve)
- **Unstract**: Binary data access + 2 Accept headers (POST, status)
- **UnstractHitlFetch**: 1 Accept header (GET)
- **UnstractHitlPush**: Binary data access + 2 Accept headers (POST, status)

## Testing
- Tested on n8n 2.0 and confirmed working
- All nodes successfully process binary file uploads
- No HTTP 406 or encoding errors

Closes #[issue-number-if-applicable]
@Deepak-Kesavan Deepak-Kesavan self-assigned this Dec 23, 2025
@jaseemjaskp jaseemjaskp self-requested a review December 24, 2025 05:01
@jaseemjaskp jaseemjaskp merged commit d33b024 into main Dec 24, 2025
1 check passed
@jaseemjaskp jaseemjaskp deleted the fix/n8n-2.0-compatibility branch December 24, 2025 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants