{"record":{"id":"6d56f40b3ba12153","repo":"JuliusBrussee/caveman","slug":"vertex-model-q-is-not-on-the-allowlist","errorCode":null,"errorMessage":"vertex model %q is not on the allowlist","messagePattern":"vertex model %q is not on the allowlist","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/providers/vertex/routing.go","lineNumber":47,"sourceCode":"// 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)\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 {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/providers/vertex/routing.go#L29-L65","documentation":"The Vertex adapter matches the requested model id against a prefix allowlist — by default ['gemini-','claude-'] (routing.go:24,46-47,176-178) — so versioned ids like gemini-2.5-pro or claude-sonnet-4-5@20250929 are covered. A model that matches no entry is rejected, unless it is the special Anthropic count-tokens literal path. This keeps clients from invoking models the gateway cannot price or meter.","triggerScenarios":"Request '/vertex/.../publishers/google/models/llama-4-maverick:generateContent', a typo'd id like 'gemini2.5-pro' (no hyphen), or an unpublished model id not starting with gemini-/claude- while CAVE_VERTEX_MODEL_ALLOWLIST is unset/overridden.","commonSituations":"Routing partner (non-gemini/claude) models; a narrowed CAVE_VERTEX_MODEL_ALLOWLIST that dropped a prefix you now use; brand-new model families released after the default list was written.","solutions":["Use a model id starting with an allowlisted prefix (gemini-... under publishers/google, claude-... under publishers/anthropic).","Check the id for typos against the vendor's published model list (e.g. gemini-2.5-pro, claude-sonnet-4-5@20250929).","If the model is intended, extend CAVE_VERTEX_MODEL_ALLOWLIST with the appropriate prefix (comma-separated) — the default list matches as prefixes, so 'gemini-' covers all versions."],"exampleFix":"# before\nCAVE_VERTEX_MODEL_ALLOWLIST=gemini-\n# after\nCAVE_VERTEX_MODEL_ALLOWLIST=gemini-,claude-","handlingStrategy":"validation","validationCode":"if !modelAllowed(model) && !(publisher == \"anthropic\" && model == \"count-tokens\" && method == \"rawPredict\") {\n    return fmt.Errorf(\"model %q not allowlisted; default prefixes gemini-,claude-; override with CAVE_VERTEX_MODEL_ALLOWLIST\", model)\n}","typeGuard":"func isAllowlistedModel(model string) bool {\n    return modelAllowed(model)\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"model\") && strings.Contains(err.Error(), \"allowlist\") {\n    return httpError(403, \"model not allowlisted; verify the id or extend CAVE_VERTEX_MODEL_ALLOWLIST\")\n}","preventionTips":["Keep model ids consistent with vendor-published lists; the allowlist matches by prefix so 'gemini-' covers all versions.","Review CAVE_VERTEX_MODEL_ALLOWLIST after narrowing it — it fully replaces the default.","Test new model families against a dry-run before routing live spend."],"tags":["go","vertex","allowlist","model-id"],"backgroundTag":"invalid-enum-value","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"}