Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Oct 8, 2025

Summary

This PR fixes an issue where using Google's Vertex AI provider with the "global" region and Claude models resulted in 404 errors due to incorrect hostname construction.

Problem

When the region is set to "global", the AnthropicVertex SDK was constructing the URL as global-aiplatform.googleapis.com instead of the correct aiplatform.googleapis.com.

Solution

  • Added logic to provide a custom baseURL when the region is "global"
  • The fix ensures the correct endpoint (https://aiplatform.googleapis.com/v1) is used for global region
  • For all other regions, the SDK's default URL construction is preserved

Testing

  • Added comprehensive test coverage for the global region scenario
  • Tests cover all three authentication methods (default, JSON credentials, key file)
  • All existing tests continue to pass

Changes

  • Modified src/api/providers/anthropic-vertex.ts to handle global region
  • Added test cases in src/api/providers/__tests__/anthropic-vertex.spec.ts

Fixes #8571


Important

Fixes global region handling in AnthropicVertexHandler by setting correct baseURL for Vertex AI Claude models and adds tests for verification.

  • Behavior:
    • Fixes incorrect hostname for global region in AnthropicVertexHandler by setting baseURL to https://aiplatform.googleapis.com/v1.
    • Preserves default URL construction for non-global regions.
  • Testing:
    • Adds tests in anthropic-vertex.spec.ts for global region with default, JSON credentials, and key file authentication.
    • Ensures all existing tests pass.
  • Files Modified:
    • anthropic-vertex.ts: Adds logic for custom baseURL for global region.
    • anthropic-vertex.spec.ts: Adds test cases for global region handling.

This description was created by Ellipsis for e0fd25a. You can customize this summary. It will automatically update as commits are pushed.

- Add custom baseURL for global region to use aiplatform.googleapis.com
- Prevents incorrect hostname construction (global-aiplatform.googleapis.com)
- Add comprehensive test coverage for global region scenarios

Fixes #8571
@roomote roomote bot requested review from cte, jr and mrubens as code owners October 8, 2025 22:40
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Oct 8, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 8, 2025
Copy link
Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review: auditing my own diff like a mirror with unit tests—still me, just with fewer 404s.

// For the "global" region, we need to use a custom base URL
// The default would be "global-aiplatform.googleapis.com" which is incorrect
// The correct endpoint for global is "aiplatform.googleapis.com"
const baseURL = region === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Region comparison is exact-match; a user-provided value like "Global" or trailing whitespace would miss this branch. Consider normalizing before compare.

Suggested change
const baseURL = region === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions
const baseURL = region.trim().toLowerCase() === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions

// For the "global" region, we need to use a custom base URL
// The default would be "global-aiplatform.googleapis.com" which is incorrect
// The correct endpoint for global is "aiplatform.googleapis.com"
const baseURL = region === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Verify SDK behavior regarding baseURL path: if the Vertex SDK appends "/v1" internally, this string may yield a double "/v1/v1". If so, prefer host-only.

Suggested change
const baseURL = region === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions
const baseURL = region.trim().toLowerCase() === "global" ? `https://aiplatform.googleapis.com` : undefined // Let the SDK use its default for other regions

})
})

it("should use custom baseURL for global region with JSON credentials", () => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Consider complementary tests for non-global regions with JSON credentials and with key files to assert baseURL remains undefined. This guards against regressions in the credential branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Wrong endpoint hostname when using Google's Vertex AI with region "global" for Claude models

4 participants