Skip to content

Vertex AI exceptions masked by n8n exception #18452

@Ziyann

Description

@Ziyann

Bug Description

When using Vertex AI models in LLM nodes or LangChain Code nodes, exceptions from LangChain/Vertex AI are masked by n8n's exception handler. Instead of showing the actual error, n8n always displays:
Cannot read properties of undefined (reading 'Symbol(Symbol.asyncIterator)').

This makes it extremely difficult to debug issues and understand what went wrong.

To Reproduce

The simplest way to reproduce is with an AI Agent:

  1. Add an AI Agent node connected after a chat trigger
  2. Connect a Google Vertex Chat Model
  3. Enter "gemini-2.5-invalid" as the model name
  4. Enter a chat message
  5. Observe the thrown exception:
{
  "errorMessage": "Cannot read properties of undefined (reading 'Symbol(Symbol.asyncIterator)')",
  "errorDetails": {},
  "n8nDetails": {
    "time": "8/17/2025, 12:46:30 PM",
    "n8nVersion": "1.107.2 (Self Hosted)",
    "binaryDataMode": "default"
  }
}

Another way to reproduce is setting up a LangChain Code node, with the following code:

const { HumanMessage } = require("@langchain/core/messages");
const { ChatVertexAI } = require("@langchain/google-vertexai");

// Create Vertex AI model
const llm = new ChatVertexAI({
  model: "gemini-2.5-invalid",
});

response = await llm.invoke([new HumanMessage("Hello, how are you?")]);

return [
  {
    json: {
      output: response,
    },
  },
];

Upon executing, this throws:

{
  "errorMessage": "Cannot read properties of undefined (reading 'Symbol(Symbol.asyncIterator)')",
  "errorDetails": {},
  "n8nDetails": {
    "n8nVersion": "1.107.2 (Self Hosted)",
    "binaryDataMode": "default",
    "stackTrace": [
      "Error: Cannot read properties of undefined (reading 'Symbol(Symbol.asyncIterator)')",
      "    at Gaxios._request (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/gaxios@7.1.0/node_modules/gaxios/src/gaxios.ts:225:15)",
      "    at processTicksAndRejections (node:internal/process/task_queues:105:5)",
      "    at Compute.requestAsync (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/google-auth-library@10.1.0/node_modules/google-auth-library/build/src/auth/oauth2client.js:463:20)",
      "    at GAuthClient._fetch (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@langchain+google-gauth@0.2.13_@langchain+core@0.3.61_@opentelemetry+api@1.9.0_@opentel_4dcb9c9e39ce5bd52ab5cca61b25801a/node_modules/@langchain/google-gauth/dist/auth.cjs:75:20)",
      "    at GAuthClient._request (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@langchain+google-common@0.2.13_@langchain+core@0.3.61_@opentelemetry+api@1.9.0_@opente_48c1b603e0033cffd03d5853513ed512/node_modules/@langchain/google-common/dist/auth.cjs:45:21)",
      "    at RetryOperation._fn (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/p-retry@4.6.2/node_modules/p-retry/index.js:50:12)"
    ]
  }
}

Note that if I use a correct model name, e.g. "gemini-2.5-flash", it works. There problem is NOT related to authentication, as the exception might suggest. Since I host n8n on GCP, LangChain can access Vertex AI without authentication because the VM has a service account with the necessary permissions. However, for the AI Agent node test, I had set up the Google Service Account credentials, to confirm that it's not related to authentication.

The same problem happens in all error cases - for example, sending a binary with an unsupported mime type also throws the same exception. This makes debugging very hard.

The issue happens both on n8n 1.106.3 and 1.107.2.

Expected behavior

n8n should preserve and display the original exception messages from LangChain/Vertex AI.

Debug Info

Debug info

core

  • n8nVersion: 1.107.2
  • platform: docker (self-hosted)
  • nodeJsVersion: 22.17.0
  • database: postgres
  • executionMode: regular
  • concurrency: -1
  • license: enterprise (production)
  • consumerId: 5b2d9c44-29ea-4d96-ae54-a9061f769db5

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: memory

pruning

  • enabled: true
  • maxAge: 72 hours
  • maxCount: 500 executions

client

  • userAgent: mozilla/5.0 (windows nt 10.0; win64; x64; rv:141.0) gecko/20100101 firefox/141.0
  • isTouchDevice: false

Generated at: 2025-08-17T10:47:32.459Z

Operating System

Ubuntu Linux 24.04

n8n Version

1.107.2 (Docker)

Node.js Version

22.17.0

Database

PostgreSQL

Execution mode

main (default)

Hosting

self hosted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs FeedbackWaiting for further input or clarification.Releasedin linearIssue or PR has been created in Linear for internal reviewteam:aiIssue is with the ai team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions