Skip to content

Conversation

@MathiasZander
Copy link
Contributor

@MathiasZander MathiasZander commented Oct 25, 2025

Updated VertextPlatformAdapter.GetBaseUrl() to handle the global region as a special case without the region prefix.

Fixes #71

Tested with and without Microsoft.Extensions.AI

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Vertex AI platform connectivity for the global region by correcting the endpoint URL configuration to properly resolve global region deployments while maintaining compatibility with regional endpoints.

@coderabbitai
Copy link

coderabbitai bot commented Oct 25, 2025

Walkthrough

Modified the VertexAI platform adapter's base URL construction to handle the "global" region differently. When region is "global", the base URL is now https://aiplatform.googleapis.com. For all other regions, it maintains the existing https://{Region}-aiplatform.googleapis.com format.

Changes

Cohort / File(s) Change Summary
VertexAI Global Region URL Fix
src/GenerativeAI/Platforms/VertextPlatformAdapter.cs
Added conditional in GetBaseUrl method: if Region equals "global", use domain without region prefix; otherwise use region-prefixed domain

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5–10 minutes

  • Special attention areas:
    • Verify the "global" domain (https://aiplatform.googleapis.com) is the correct endpoint for global region deployments
    • Confirm no other region-specific logic requires similar adjustments

Poem

🐰 A hop through the clouds, where regions align,
The global domain now shines so fine,
No "global-" prefix to lead astray,
The VertexAI path finds its proper way! ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Correct Vertex global region endpoint URL construction" directly and clearly describes the main change in the changeset. The raw_summary confirms that the modification adds special-case handling for the global region in the GetBaseUrl method, omitting the region prefix when constructing the base URL. The title is specific, concise, and accurately reflects the primary change without ambiguity or unnecessary detail.
Linked Issues Check ✅ Passed The linked issue #71 requires that the base URL construction handle the global region as a special case so the correct base URI (without the "global" prefix) is used for region "global". The code changes implement exactly this requirement by adding a conditional check: when Region equals "global", the base URL uses "https://aiplatform.googleapis.com", otherwise it uses the standard $"https://{Region}-aiplatform.googleapis.com" format. This directly addresses the stated objective of fixing the incorrect BaseUrl construction for the global region.
Out of Scope Changes Check ✅ Passed All changes in the pull request are limited to the VertextPlatformAdapter.cs file and specifically focus on the GetBaseUrl method's base URL construction logic. The modifications introduce conditional logic to handle the global region as a special case, which is precisely the scope defined by issue #71. No public API signatures were altered, and no unrelated changes to other areas or functionality are present in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/GenerativeAI/Platforms/VertextPlatformAdapter.cs (1)

324-324: Update documentation to reflect the special case for the global region.

The comment describes the URL pattern but doesn't mention that the "global" region is handled differently (the region prefix is omitted from the base domain).

Apply this diff to update the documentation:

     /// <summary>
     /// Constructs the base URL for API requests with optional components.
-    /// Pattern: https://{region}-aiplatform.googleapis.com/{version}/projects/{projectId}/locations/{region}/publishers/{publisher}
+    /// Pattern: https://{region}-aiplatform.googleapis.com/{version}/projects/{projectId}/locations/{region}/publishers/{publisher}
+    /// Note: For the "global" region, the base URL is https://aiplatform.googleapis.com (region prefix is omitted).
     /// </summary>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dad28b2 and 9e4a083.

📒 Files selected for processing (1)
  • src/GenerativeAI/Platforms/VertextPlatformAdapter.cs (1 hunks)
🔇 Additional comments (1)
src/GenerativeAI/Platforms/VertextPlatformAdapter.cs (1)

345-345: Code correctly implements the global endpoint handling per Google Cloud API specifications.

The line 345 implementation correctly handles the global endpoint by excluding the location from the endpoint name. The global endpoint URL follows the pattern https://aiplatform.googleapis.com/v1/projects/..., which is exactly what the code produces when Region == "global".

Google Cloud documentation specifies "global" (lowercase) as the location identifier, and the case-sensitive comparison aligns with this documented convention. The original suggestion to use case-insensitive comparison is not necessary—all tested regions in the codebase are lowercase, environment variable defaults use lowercase, and Google Cloud's API documentation consistently shows lowercase values only.

The fix correctly addresses the reported issue without requiring additional defensive measures.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Region "global" with VertexAI does not Work (wrong BaseUri)

2 participants