JuliusBrussee/caveman · error

vertex base url invalid

Error message

vertex base url invalid: %w

What it means

After allowlist checks, ResolveUpstreamURL parses the effective base URL (adapter default, overridden by route.BaseURL) with url.Parse (routing.go:54-56). This error wraps Go's net/url parse error, meaning the configured value is not a syntactically valid URL at all (e.g. a control character, malformed host, or invalid percent-encoding) — not merely a disallowed one.

Solutions

  1. Read the wrapped net/url message after 'vertex base url invalid:' to see the exact syntax problem, then fix the base URL string.
  2. Check whether a RouteContext.BaseURL override (per-route config) is the offending value rather than the adapter default.
  3. Verify env/template placeholders were expanded — a literal '${HOST}' or '${...}' in the URL is a common cause.
  4. Validate the value standalone with url.Parse in a quick Go snippet or test before redeploying.

Example fix

// before
baseURL := "https://[::1:8080"
// after
baseURL := "https://[::1]:8080"
Defensive patterns

Strategy: validation

Validate before calling

if _, err := url.Parse(baseURL); err != nil {
    return fmt.Errorf("vertex base URL %q is not a parseable URL: %v", baseURL, err)
}

Type guard

func isParseableURL(raw string) bool {
    _, err := url.Parse(raw)
    return err == nil
}

Try / catch

u, err := adapter.ResolveUpstreamURL(ctx, req, route)
if err != nil {
    if strings.Contains(err.Error(), "base url invalid") {
        log.Fatalf("fix the vertex base URL: %v", err)
    }
    return err
}

Prevention

When it happens

Trigger: Set a.BaseURL or providers.RouteContext.BaseURL to a string net/url cannot parse — e.g. 'http://[::1' (unclosed IPv6 bracket), a URL with raw spaces/control bytes, or an invalid % escape like 'https://host/%zz'.

Common situations: A route-level BaseURL override built by string concatenation without escaping; a caveman.yaml value with stray characters or an unescaped template placeholder like 'http://${HOST}/v1' left unexpanded; pasted URLs with smart quotes.

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


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/299a037953e825a6. Report an issue: GitHub.

Appendix: source

Thrown at proxy/providers/vertex/routing.go:56

		return nil, fmt.Errorf("vertex request path %q does not name a publisher, model, and method", req.URL.Path)
	}
	if !methodAllowed(publisher, method) {
		return nil, fmt.Errorf("vertex method %q is not allowed for publisher %q", method, publisher)
	}
	if !publisherAllowed(publisher) {
		return nil, fmt.Errorf("vertex publisher %q is not on the allowlist", publisher)
	}
	if !modelAllowed(model) && !anthropicCountTokensPath(publisher, model, method) {
		return nil, fmt.Errorf("vertex model %q is not on the allowlist", model)
	}

	baseURL := a.BaseURL
	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
}

View on GitHub (pinned to 3ee70a1026)