{"record":{"id":"90b70c1a207b0465","repo":"JuliusBrussee/caveman","slug":"vertex-request-path-q-does-not-name-a-publisher","errorCode":null,"errorMessage":"vertex request path %q does not name a publisher, model, and method","messagePattern":"vertex request path %q does not name a publisher, model, and method","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/providers/vertex/routing.go","lineNumber":38,"sourceCode":"\n// defaultModelPrefixes is the built-in model-id allowlist, matched as prefixes\n// so versioned ids (gemini-2.5-pro, claude-sonnet-4-5@20250929) are covered.\n// Operators override it with CAVE_VERTEX_MODEL_ALLOWLIST.\nvar defaultModelPrefixes = []string{\"gemini-\", \"claude-\"}\n\n// ResolveUpstreamURL validates the Vertex request shape (publisher + model on\n// the allowlist), enforces SSRF/host constraints against the aiplatform\n// endpoint, and resolves the upstream URL. The /vertex prefix is stripped so the\n// upstream path is the native aiplatform path\n// (/v1/projects/{p}/locations/{l}/publishers/{pub}/models/{model}:{method}). The\n// non-authentication query bytes (e.g. ?alt=sse) are preserved unchanged.\nfunc (a Adapter) ResolveUpstreamURL(ctx context.Context, req *http.Request, route providers.RouteContext) (*url.URL, error) {\n\tif _, err := providers.GoogleRequestAPIKey(req); err != nil {\n\t\treturn nil, err\n\t}\n\tpublisher, model, method := parsePredictPath(req.URL.Path)\n\tif publisher == \"\" || model == \"\" || method == \"\" {\n\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)","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/providers/vertex/routing.go#L20-L56","documentation":"The Vertex adapter's ResolveUpstreamURL parses the request path expecting the native aiplatform shape /v1/projects/{p}/locations/{l}/publishers/{pub}/models/{model}:{method} (routing.go:36-38). parsePredictPath extracts publisher, model, and method; if any of the three is empty the path is not a valid predict-style route and the request is rejected. This is a fail-closed guard: the adapter cannot resolve a correct upstream URL for an unrecognized path shape.","triggerScenarios":"POST to a /vertex/... route whose path lacks the publishers/, models/, or a 'model:method' segment — e.g. '/vertex/v1/projects/p/locations/us-east1' (no publishers/models), '/vertex/v1/.../models/gemini-2.5-pro' without ':generateContent', or a mistyped path like 'publisher' instead of 'publishers'.","commonSituations":"Clients written against a different Vertex surface (e.g. raw endpoints or matching-engine routes), SDKs that build non-predict paths (fine-tuning, index endpoints), typos in a hand-rolled request, or an older SDK that omits the ':method' suffix.","solutions":["Send the request to the full predict-shaped path: /vertex/v1/projects/{p}/locations/{l}/publishers/{pub}/models/{model}:{method}.","Verify the method suffix ':generateContent', ':streamGenerateContent', ':rawPredict', ':streamRawPredict', or ':countTokens' is present after the model id.","Check the path uses the exact segment names 'publishers' and 'models' (plural) with a non-empty segment after each.","If using an Anthropic SDK on Vertex, the fixed literal path .../models/count-tokens:rawPredict is recognized and allowed."],"exampleFix":"// before\nPOST /vertex/v1/projects/my-proj/locations/us-central1/models/gemini-2.5-pro\n// after\nPOST /vertex/v1/projects/my-proj/locations/us-central1/publishers/google/models/gemini-2.5-pro:generateContent","handlingStrategy":"validation","validationCode":"publisher, model, method := parsePredictPath(req.URL.Path)\nif publisher == \"\" || model == \"\" || method == \"\" {\n    return fmt.Errorf(\"path %q must look like /v1/projects/{p}/locations/{l}/publishers/{pub}/models/{model}:{method}\", req.URL.Path)\n}","typeGuard":"func isPredictShapedPath(path string) bool {\n    p, m, meth := parsePredictPath(path)\n    return p != \"\" && m != \"\" && meth != \"\"\n}","tryCatchPattern":"u, err := adapter.ResolveUpstreamURL(ctx, req, route)\nif err != nil {\n    if strings.Contains(err.Error(), \"does not name a publisher\") {\n        return httpError(400, \"check the Vertex path: needs publishers/{pub}/models/{model}:{method}\")\n    }\n    return err\n}","preventionTips":["Always generate Vertex paths from an SDK or template rather than hand-writing them.","Remember the ':method' suffix is mandatory on the model segment.","Use exact segment names: 'publishers' and 'models' (plural).","Log the full request path when debugging 4xx/404s from the proxy."],"tags":["go","vertex","routing","request-path"],"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"}