{"record":{"id":"299a037953e825a6","repo":"JuliusBrussee/caveman","slug":"vertex-base-url-invalid-w","errorCode":null,"errorMessage":"vertex base url invalid: %w","messagePattern":"vertex base url invalid: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/providers/vertex/routing.go","lineNumber":56,"sourceCode":"\t\treturn nil, fmt.Errorf(\"vertex request path %q does not name a publisher, model, and method\", req.URL.Path)\n\t}\n\tif !methodAllowed(publisher, method) {\n\t\treturn nil, fmt.Errorf(\"vertex method %q is not allowed for publisher %q\", method, publisher)\n\t}\n\tif !publisherAllowed(publisher) {\n\t\treturn nil, fmt.Errorf(\"vertex publisher %q is not on the allowlist\", publisher)\n\t}\n\tif !modelAllowed(model) && !anthropicCountTokensPath(publisher, model, method) {\n\t\treturn nil, fmt.Errorf(\"vertex model %q is not on the allowlist\", model)\n\t}\n\n\tbaseURL := a.BaseURL\n\tif route.BaseURL != \"\" {\n\t\tbaseURL = route.BaseURL\n\t}\n\tbase, err := url.Parse(baseURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"vertex base url invalid: %w\", err)\n\t}\n\tbase.Path = strings.TrimRight(base.Path, \"/\") + strings.TrimPrefix(req.URL.Path, \"/vertex\")\n\tbase.RawQuery = providers.WithoutGoogleAPIKeyQuery(req.URL.RawQuery)\n\n\t// SSRF/host validation on the resolved endpoint. Active in managed (prod)\n\t// mode; local/self-hosted (stub) endpoints are permitted so the dry-run and\n\t// examples can target the provider-stub.\n\tif env.IsProduction() {\n\t\tif err := providers.ValidateUpstreamEndpoint(ctx, base, ssrf.ManagedConfig()); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif host := base.Hostname(); !isVertexHost(host) {\n\t\t\treturn nil, fmt.Errorf(\"vertex endpoint host %q is not an aiplatform host\", host)\n\t\t}\n\t}\n\treturn base, nil\n}\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/providers/vertex/routing.go#L38-L74","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","solutions":["Read the wrapped net/url message after 'vertex base url invalid:' to see the exact syntax problem, then fix the base URL string.","Check whether a RouteContext.BaseURL override (per-route config) is the offending value rather than the adapter default.","Verify env/template placeholders were expanded — a literal '${HOST}' or '${...}' in the URL is a common cause.","Validate the value standalone with url.Parse in a quick Go snippet or test before redeploying."],"exampleFix":"// before\nbaseURL := \"https://[::1:8080\"\n// after\nbaseURL := \"https://[::1]:8080\"","handlingStrategy":"validation","validationCode":"if _, err := url.Parse(baseURL); err != nil {\n    return fmt.Errorf(\"vertex base URL %q is not a parseable URL: %v\", baseURL, err)\n}","typeGuard":"func isParseableURL(raw string) bool {\n    _, err := url.Parse(raw)\n    return err == nil\n}","tryCatchPattern":"u, err := adapter.ResolveUpstreamURL(ctx, req, route)\nif err != nil {\n    if strings.Contains(err.Error(), \"base url invalid\") {\n        log.Fatalf(\"fix the vertex base URL: %v\", err)\n    }\n    return err\n}","preventionTips":["Expand environment/template placeholders in URLs before they reach config.","Avoid hand-built URL strings; prefer typed config with url.URL fields.","Check both the adapter default BaseURL and per-route BaseURL overrides when this error appears.","Escape or reject control characters and raw spaces in configured URLs."],"tags":["go","vertex","url-parse","configuration"],"backgroundTag":"invalid-url-format","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}