[GH-ISSUE #1695] [langchain]: Model Provider Resolution Conflict: google-vertexai-web Incorrectly Resolves to google-vertexai Due to Duplicate className #228

Open
opened 2026-02-17 17:19:27 -05:00 by yindo · 3 comments
Owner

Originally created by @pipibao on GitHub (Dec 2, 2025).
Original GitHub issue: https://github.com/langchain-ai/docs/issues/1695

Originally assigned to: @christian-bromann, @hntrl on GitHub.

Type of issue

issue / bug

Language

JavaScript

Description

I encountered the following issue in version v1.1.1:
I tried to initialize a gemini-2.5-flash model using initChatModel with the provider google-vertexai-web, using the code below:

const model = await initChatModel("gemini-2.5-flash", {
  modelProvider: "google-vertexai-web",
  authOptions: {
    credentials,
  },
});

However, instead of loading the google-vertexai-web package, the system incorrectly resolved to the google-vertexai package.
Looking at source code, I found the root cause in:

// chat_models/universal.js
// function getChatModelByClassName
async function getChatModelByClassName(className) {
     // The problem lies at this step
	const providerEntry = Object.entries(MODEL_PROVIDER_CONFIG).find(([, config$1]) => config$1.className === className);
	if (!providerEntry) return void 0;
	const [, config] = providerEntry;
	try {
		const module$1 = await import(config.package);
		return module$1[config.className];
	} catch (e) {
		const err = e;
		if ("code" in err && err.code?.toString().includes("ERR_MODULE_NOT_FOUND") && "message" in err) {
			const attemptedPackage = err.message.split("Error: Cannot find package '")[1].split("'")[0];
			throw new Error(`Unable to import ${attemptedPackage}. Please install with \`npm install ${attemptedPackage}\` or \`pnpm install ${attemptedPackage}\``);
		}
		throw e;
	}
}

The problem lies in MODEL_PROVIDER_CONFIG, which contains:

"google-vertexai": {
  package: "@langchain/google-vertexai",
  className: "ChatVertexAI"
},
"google-vertexai-web": {
  package: "@langchain/google-vertexai-web",
  className: "ChatVertexAI"
}

Both entries share the same className ("ChatVertexAI"), but the .find() method returns only the first match—so it always picks "google-vertexai" and ignores "google-vertexai-web".

Originally created by @pipibao on GitHub (Dec 2, 2025). Original GitHub issue: https://github.com/langchain-ai/docs/issues/1695 Originally assigned to: @christian-bromann, @hntrl on GitHub. ### Type of issue issue / bug ### Language JavaScript ### Description I encountered the following issue in version v1.1.1: I tried to initialize a gemini-2.5-flash model using initChatModel with the provider google-vertexai-web, using the code below: ```typescript const model = await initChatModel("gemini-2.5-flash", { modelProvider: "google-vertexai-web", authOptions: { credentials, }, }); ``` However, instead of loading the google-vertexai-web package, the system incorrectly resolved to the google-vertexai package. Looking at source code, I found the root cause in: ```typescript // chat_models/universal.js // function getChatModelByClassName async function getChatModelByClassName(className) { // The problem lies at this step const providerEntry = Object.entries(MODEL_PROVIDER_CONFIG).find(([, config$1]) => config$1.className === className); if (!providerEntry) return void 0; const [, config] = providerEntry; try { const module$1 = await import(config.package); return module$1[config.className]; } catch (e) { const err = e; if ("code" in err && err.code?.toString().includes("ERR_MODULE_NOT_FOUND") && "message" in err) { const attemptedPackage = err.message.split("Error: Cannot find package '")[1].split("'")[0]; throw new Error(`Unable to import ${attemptedPackage}. Please install with \`npm install ${attemptedPackage}\` or \`pnpm install ${attemptedPackage}\``); } throw e; } } ``` The problem lies in MODEL_PROVIDER_CONFIG, which contains: ```typescript "google-vertexai": { package: "@langchain/google-vertexai", className: "ChatVertexAI" }, "google-vertexai-web": { package: "@langchain/google-vertexai-web", className: "ChatVertexAI" } ``` Both entries share the same className ("ChatVertexAI"), but the .find() method returns only the first match—so it always picks "google-vertexai" and ignores "google-vertexai-web".
yindo added the langchainexternaljs/tsjavascript labels 2026-02-17 17:19:27 -05:00
Author
Owner

@christian-bromann commented on GitHub (Jan 23, 2026):

@pipibao thanks for flagging this, we already have a pending PR with a fix for it.

@christian-bromann commented on GitHub (Jan 23, 2026): @pipibao thanks for flagging this, we already have a [pending PR](https://github.com/langchain-ai/langchainjs/pull/9763/changes) with a fix for it.
Author
Owner

@pipibao commented on GitHub (Jan 23, 2026):

这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。

@pipibao commented on GitHub (Jan 23, 2026): 这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。
Author
Owner

@christian-bromann commented on GitHub (Jan 23, 2026):

这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。

祝您假期愉快!

@christian-bromann commented on GitHub (Jan 23, 2026): > 这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。 祝您假期愉快!
yindo changed title from [langchain]: Model Provider Resolution Conflict: google-vertexai-web Incorrectly Resolves to google-vertexai Due to Duplicate className to [GH-ISSUE #1695] [langchain]: Model Provider Resolution Conflict: google-vertexai-web Incorrectly Resolves to google-vertexai Due to Duplicate className 2026-06-05 17:25:45 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#228