Skip to content

Global location generates invalid request endpoint #539

@meisenstat

Description

@meisenstat

Environment details

  • Programming language: Typescript
  • OS: Mac/Linux
  • Language runtime version: v20.12.2
  • Package version: v1.10.0

Steps to reproduce

  1. Use the package to make a call to generateContent() with standard config/params with the global endpoint
  2. Observe 404 Not Found exception

Code Example:

        this.vertexAi = new VertexAI({
            project: <project_id>
            location: 'global',
            ...
        });

        const generativeModel = this.vertexAi.getGenerativeModel({
            model: 'gemini-2.5-flash-lite-preview-06-17',
            generationConfig: {
            ...
        });

        const result = await generativeModel.generateContent(requestString);

Upon making a call to Vertex using generateContent() for a model only supported in global (for example gemini-2.5-flash-lite-preview-06-17), the call will fail due to an invalid base URL resolution.

When apiEndpoint is not configured when initializing VertexAI, the following code will prepend region to the base path. This will resolve to https://global-aiplatform.googleapis.com/v1/projects... which is not a valid URL and will generate a 404 Not Found upon making the request.

Additionally, the library does not fail gracefully when hitting this issue. It throws the following exception back to the client:

Unexpected token '<', "<!DOCTYPE "... is not valid JSON

instead of an exception describing the problem, thus making debugging significantly more difficult. This is due to the linked code calling JSON.parse() when the response stream format is an HTML document instead of valid JSON.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: aiplatformIssues related to the googleapis/nodejs-vertexai API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions