Code node suddenly throwing unknown error

Describe the problem/error/question

I’ve been working on a workflow for awhile, but haven’t touched it in almost 2 weeks now (last touch would have been ~20th of April). In that time I believe our instance was updated from 2.18.4 → 2.18.7 (set to auto-update), however I see nothing in the release notes that should cause this issue. I’ve since updated to 2.19.2 (auto-update didn’t do this one, had to do it manually) and am still seeing the same results. I’ll revert if I have to, but if some functionality has been purposefully changed/removed, I’ll need to fix this if I ever want to upgrade anyways…

The initial steps of the workflow are
-isolate a single pdf attachment from an email
-generate a prompt for Claude to process said PDF (code node, js)
-Submits to Claude (http)
The code that had been working to generate the prompt is this:

const binaryData = $input.item.binary.attachment_0;
const buffer = await this.helpers.getBinaryDataBuffer(0, 'attachment_0');
const base64Pdf = buffer.toString('base64');
const body = {
  model: 'claude-sonnet-4-6',
  max_tokens: 2000,
  messages: [
    {
      role: 'user',
      content: [
        {
          type: 'document',
          source: {
            type: 'base64',
            media_type: 'application/pdf',
            data: base64Pdf
          }
        },
        {
          type: 'text',
          text: 'Extract the following data from this PDF: -Purchase order number -Ship Date -Invoice number -Array of items ordered.  Include the dell part number (do not include the word Dell), description, serial number, and ext net price.  Return ONLY the raw JSON with no markdown, no explanation, no code fences.'
        }
      ]
    }
  ]
};
return [{
  json: { body: JSON.stringify(body) }
}];

Resulting in:

image

The initial step to isolate the PDF uses this code:



const binary = $input.item.binary;
// Find the key of the PDF attachment
const pdfKey = Object.keys(binary).find(
  key => binary[key].mimeType === 'application/pdf'
);
if (!pdfKey) {
  throw new Error('No PDF attachment found on this email');
}
return [{
  json: $input.item.json,        // pass through the email data unchanged
  binary: {
    attachment_0: binary[pdfKey] // rename it to a predictable key
  }
}];



Resulting in attachment_0

However after returning to this workflow after ~2 weeks, that gen prompt step now results in an unknown error. I’ve tried fixing it with various other js code, with no luck recreating what I need. My familiarity with JS is amateur-level, but Claude has been great at generating code. I’ve gone through several iterations with no luck.

Information on your n8n setup

  • n8n version: 2.18.7 - 2.19.2 (self-hosted)
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system:

Disregard… I rebooted my n8n server and it appears to be working again. One of the updates must have locked it out from something.

great @flowdan , the important thing is that it’s working now.
I recommend marking your reply as the solution so it can help other people in the community when they search for something similar later.