fix: use build_host_url for GCP Vertex AI location fallback (#8185)

Signed-off-by: rdondeti <ravitez.dondeti@gmail.com>
This commit is contained in:
Ravitez Dondeti
2026-03-30 10:11:36 -05:00
committed by GitHub
parent e3b78e8e81
commit 26d3d3ace3
+55 -1
View File
@@ -72,7 +72,7 @@ fn build_vertex_url(
let host_url = if configured_location == target_location {
host.to_string()
} else {
host.replace(configured_location, target_location)
GcpVertexAIProvider::build_host_url(target_location)
};
let base_url =
@@ -735,6 +735,60 @@ mod tests {
assert!(url.as_str().contains("locations/europe-west1"));
}
#[test]
fn test_build_vertex_url_global_location_fallback() {
// When configured_location is "global", the host is
// "https://aiplatform.googleapis.com" which does not contain "global".
// Falling back to a regional target_location must rebuild the host
// via build_host_url rather than string replacement.
let url = build_vertex_url(
"https://aiplatform.googleapis.com",
"global",
"test-project",
"claude-haiku-4-5@20251001",
ModelProvider::Anthropic,
"us-east5",
true,
)
.unwrap();
assert!(
url.as_str()
.starts_with("https://us-east5-aiplatform.googleapis.com"),
"Expected regional host for us-east5, got: {}",
url
);
assert!(
url.as_str().contains("locations/us-east5"),
"Expected locations/us-east5 in path, got: {}",
url
);
assert!(url.as_str().contains(":streamRawPredict"));
}
#[test]
fn test_build_vertex_url_global_location_same() {
// When both configured and target are "global", the host should stay as-is.
let url = build_vertex_url(
"https://aiplatform.googleapis.com",
"global",
"test-project",
"claude-haiku-4-5@20251001",
ModelProvider::Anthropic,
"global",
true,
)
.unwrap();
assert!(
url.as_str()
.starts_with("https://aiplatform.googleapis.com"),
"Expected global host, got: {}",
url
);
assert!(url.as_str().contains("locations/global"));
}
#[test]
fn test_provider_metadata() {
let metadata = GcpVertexAIProvider::metadata();