JuliusBrussee/caveman · error
vertex endpoint host
Error message
vertex endpoint host %q is not an aiplatform host
What it means
In production mode, after SSRF validation, ResolveUpstreamURL additionally requires the resolved hostname to be a Vertex AI aiplatform host (routing.go:64-70, isVertexHost at 211-222): 'aiplatform.googleapis.com', any '{location}-aiplatform.googleapis.com' (including global-), or 'aiplatform.{us,eu}.rep.googleapis.com'. This is defense-in-depth against the endpoint being repointed at a non-Vertex host in managed deployments.
Solutions
- Set the base URL to a regional Vertex endpoint like 'https://{location}-aiplatform.googleapis.com' (e.g. us-central1-aiplatform.googleapis.com) or the global 'https://aiplatform.googleapis.com'.
- Remove any development/stub BaseURL override (route.BaseURL) from the production configuration.
- If you actually want the Gemini API rather than Vertex AI, use the gemini adapter instead of the vertex adapter.
- For local testing, run in a non-production environment (env.IsProduction() false) where stub endpoints are permitted.
Example fix
// before BaseURL: "https://generativelanguage.googleapis.com" // after BaseURL: "https://us-central1-aiplatform.googleapis.com"
Defensive patterns
Strategy: validation
Validate before calling
host := u.Hostname()
vertexHost := host == "aiplatform.googleapis.com" ||
strings.HasSuffix(host, "-aiplatform.googleapis.com") ||
(strings.HasPrefix(host, "aiplatform.") && strings.HasSuffix(host, ".rep.googleapis.com"))
if env.IsProduction() && !vertexHost {
return fmt.Errorf("host %q is not a Vertex aiplatform endpoint", host)
} Type guard
func isVertexHost(host string) bool {
return host == "aiplatform.googleapis.com" ||
strings.HasSuffix(host, "-aiplatform.googleapis.com") ||
(strings.HasPrefix(host, "aiplatform.") && strings.HasSuffix(host, ".rep.googleapis.com"))
} Try / catch
if err != nil && strings.Contains(err.Error(), "not an aiplatform host") {
return httpError(500, "use https://{location}-aiplatform.googleapis.com as the Vertex base URL in production")
} Prevention
- Use regional aiplatform.googleapis.com hosts for Vertex; generativelanguage.googleapis.com belongs to the Gemini adapter.
- Keep stub/local base URLs out of production-flagged environments.
- Prefer the regional hostname pattern {location}-aiplatform.googleapis.com (e.g. us-central1-aiplatform.googleapis.com).
- Test prod-mode config with a dry-run before rolling out route BaseURL overrides.
When it happens
Trigger: Run with CAVE_ENV indicating production while the adapter/route BaseURL points at a non-aiplatform host — e.g. 'https://generativelanguage.googleapis.com', 'https://us-central1-notebook.googleapis.com', or a loopback stub base URL.
Common situations: Copying a Gemini-API (generativelanguage) base URL into the Vertex adapter; pointing at a local mock in a prod-flagged environment; a route.BaseURL override intended only for development leaking into a managed deployment; using the wrong regional domain spelling.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- bedrock endpoint host
- ssrf: invalid host
- githubapp: base_url rejected by SSRF guard
- secretbox: production refuses legacy local ciphertext
- secretbox: production refuses plaintext
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/761c2a1857a82309.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/providers/vertex/routing.go:69
if route.BaseURL != "" {
baseURL = route.BaseURL
}
base, err := url.Parse(baseURL)
if err != nil {
return nil, fmt.Errorf("vertex base url invalid: %w", err)
}
base.Path = strings.TrimRight(base.Path, "/") + strings.TrimPrefix(req.URL.Path, "/vertex")
base.RawQuery = providers.WithoutGoogleAPIKeyQuery(req.URL.RawQuery)
// SSRF/host validation on the resolved endpoint. Active in managed (prod)
// mode; local/self-hosted (stub) endpoints are permitted so the dry-run and
// examples can target the provider-stub.
if env.IsProduction() {
if err := providers.ValidateUpstreamEndpoint(ctx, base, ssrf.ManagedConfig()); err != nil {
return nil, err
}
if host := base.Hostname(); !isVertexHost(host) {
return nil, fmt.Errorf("vertex endpoint host %q is not an aiplatform host", host)
}
}
return base, nil
}
func methodAllowed(publisher, method string) bool {
// countTokens is publisher-agnostic on aiplatform: the discovery document
// defines projects.locations.publishers.models.countTokens for any publisher.
if method == "countTokens" {
return publisher == "google" || publisher == "anthropic"
}
switch publisher {
case "google":
return method == "generateContent" || method == "streamGenerateContent"
case "anthropic":
return method == "rawPredict" || method == "streamRawPredict"
default:
return falseView on GitHub (pinned to 3ee70a1026)