{"record":{"id":"21856e49d25f94a5","repo":"JuliusBrussee/caveman","slug":"bedrock-request-path-q-does-not-name-a-model-and","errorCode":null,"errorMessage":"bedrock request path %q does not name a model and action","messagePattern":"bedrock request path %q does not name a model and action","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/providers/bedrock/routing.go","lineNumber":172,"sourceCode":"\t\treturn nil, fmt.Errorf(\"bedrock base url invalid: %w\", err)\n\t}\n\tregion, err := resolveRegion(req, base)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tkind := endpointKindForPath(req.URL.Path)\n\tif configuredKind := strings.ToLower(strings.TrimSpace(route.EndpointKind)); configuredKind != \"\" && configuredKind != kind {\n\t\treturn nil, fmt.Errorf(\"bedrock configured endpoint kind %q does not allow request kind %q\", configuredKind, kind)\n\t}\n\tswitch kind {\n\tcase endpointRuntime:\n\t\tif !RegionAllowed(region) {\n\t\t\treturn nil, fmt.Errorf(\"bedrock region %q is not on the allowlist\", region)\n\t\t}\n\t\tmodelID, action := parseModelPath(req.URL.Path)\n\t\tif modelID == \"\" || action == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"bedrock request path %q does not name a model and action\", req.URL.Path)\n\t\t}\n\t\tif !actionAllowed(action) {\n\t\t\treturn nil, fmt.Errorf(\"bedrock action %q is not allowed\", action)\n\t\t}\n\t\tif !modelAllowed(modelID) {\n\t\t\treturn nil, fmt.Errorf(\"bedrock model %q is not on the allowlist\", modelID)\n\t\t}\n\t\tbase.Path = strings.TrimRight(base.Path, \"/\") + strings.TrimPrefix(req.URL.Path, \"/bedrock\")\n\tcase endpointMantle:\n\t\tif !env.Bool(\"CAVE_BEDROCK_MANTLE_ENABLED\", false) {\n\t\t\treturn nil, fmt.Errorf(\"bedrock Mantle endpoint is not enabled\")\n\t\t}\n\t\tif !MantleRegionAllowed(region) {\n\t\t\treturn nil, fmt.Errorf(\"bedrock Mantle region %q is not on the allowlist\", region)\n\t\t}\n\t\tif !mantleActionAllowed(req.URL.Path) {\n\t\t\treturn nil, fmt.Errorf(\"bedrock Mantle path %q is not allowed\", req.URL.Path)\n\t\t}","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/providers/bedrock/routing.go#L154-L190","documentation":"Runtime paths must have the form /bedrock/model/{modelId}/{action}; the adapter extracts the model id and trailing action segment from the path. If either part is empty — the path does not name both a model and an action — routing cannot proceed and the request is rejected.","triggerScenarios":"A request to /bedrock/model (no model or action), /bedrock/model/anthropic.claude-3-5-sonnet (no action), /bedrock/model//invoke (empty model), or a trailing-slash path like /bedrock/model/mymodel/invoke/ where the last segment is empty.","commonSituations":"Hand-written or SDK-generated URLs that omit the action (e.g. forgetting /invoke or /converse); string building that appends a trailing slash; mistaking the converse or invoke API for a base-model listing endpoint.","solutions":["Use the full path form /bedrock/model/{modelId}/{action}, e.g. /bedrock/model/anthropic.claude-3-5-sonnet-20241022-v2:0/invoke.","Append the missing action: one of invoke, invoke-with-response-stream, converse, converse-stream, count-tokens.","Remove any trailing slash from the URL so the last path segment is the action, not an empty string.","Check the URL-building code — an interpolated model id that came out empty produces exactly this shape."],"exampleFix":"// before\nPOST /bedrock/model/anthropic.claude-3-5-sonnet\n// after\nPOST /bedrock/model/anthropic.claude-3-5-sonnet/invoke","handlingStrategy":"validation","validationCode":"func runtimePathWellFormed(path string) bool {\n\tif !strings.HasPrefix(path, \"/bedrock/model/\") {\n\t\treturn true\n\t}\n\trest := strings.Trim(strings.TrimPrefix(path, \"/bedrock\"), \"/\")\n\trest = strings.TrimPrefix(rest, \"model/\")\n\tidx := strings.LastIndex(rest, \"/\")\n\treturn idx > 0 && idx < len(rest)-1\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always append an explicit action (/invoke, /converse, ...) to model paths.","Never leave a trailing slash on bedrock model URLs.","Assert the interpolated model id is non-empty before building the URL."],"tags":["bedrock","aws","path","routing","validation"],"backgroundTag":"invalid-argument-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"}