Skip to content

GCP Vertex AI streaming fallback produces invalid URL when GCP_LOCATION=global #8053

@clouatre

Description

@clouatre

Describe the bug

When GCP_LOCATION=global, the streaming fallback in post_stream produces an invalid URL. The global host (https://aiplatform.googleapis.com) gets paired with a regional path (locations/us-east5), and GCP returns 500 for that combination.

This happens because build_vertex_url (line 72-75) does host.replace("global", "us-east5"), but "global" does not appear in the global host string, so the replace is a no-op. The correct logic already exists in build_host_url (line 233-237) but is not used by the fallback path.

The fallback triggers intermittently when GCP's global endpoint routes to a region where the model is unavailable (400). It was always broken for global, but only became visible recently as GCP started routing to regions like us-east4 where Claude is unavailable.


To Reproduce

  1. Set GCP_LOCATION=global
  2. Use any Claude model (e.g., claude-haiku-4-5@20251001)
  3. Wait for GCP's global endpoint to route to a region where the model returns 400
  4. The fallback fires and produces a 500

Expected behavior

build_vertex_url should reuse build_host_url to reconstruct the host when switching locations, instead of host.replace:

let host_url = if configured_location == target_location {
    host.to_string()
} else {
    Self::build_host_url(target_location)
};

Please provide the following information

  • OS & Arch: macOS ARM64
  • Interface: CLI
  • Version: v1.28.0
  • Extensions enabled: developer, code-analyze, context7, brave_search, aptu
  • Provider & Model: gcp_vertex_ai, claude-haiku-4-5@20251001 / claude-sonnet-4-6@default

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions