{"record":{"id":"2a98e2b0d34e4930","repo":"JuliusBrussee/caveman","slug":"bedrock-requested-region-q-does-not-match-endpoin","errorCode":null,"errorMessage":"bedrock requested region %q does not match endpoint region %q","messagePattern":"bedrock requested region %q does not match endpoint region %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/providers/bedrock/routing.go","lineNumber":348,"sourceCode":"\t}\n\tidx := strings.LastIndex(rest, \"/\")\n\tif idx <= 0 || idx == len(rest)-1 {\n\t\treturn \"\", \"\"\n\t}\n\treturn rest[:idx], rest[idx+1:]\n}\n\n// resolveRegion keeps routing, allowlisting, and signing on one region. A\n// recognized endpoint host is authoritative; a contradictory client header is\n// rejected rather than validating one region and dialing another.\nfunc resolveRegion(req *http.Request, base *url.URL) (string, error) {\n\trequested := strings.TrimSpace(req.Header.Get(\"x-cave-aws-region\"))\n\thostRegion := \"\"\n\tif base != nil {\n\t\thostRegion = regionFromHost(base.Hostname())\n\t}\n\tif requested != \"\" && hostRegion != \"\" && requested != hostRegion {\n\t\treturn \"\", fmt.Errorf(\"bedrock requested region %q does not match endpoint region %q\", requested, hostRegion)\n\t}\n\tif hostRegion != \"\" {\n\t\treturn hostRegion, nil\n\t}\n\tif requested != \"\" {\n\t\treturn requested, nil\n\t}\n\tif r := regionFromHost(req.Header.Get(\"x-cave-bedrock-host\")); r != \"\" {\n\t\treturn r, nil\n\t}\n\treturn env.String(\"CAVE_BEDROCK_REGION\", \"us-east-1\"), nil\n}\n\n// signingRegion picks the AWS region the SigV4 scope is built for. The resolved\n// upstream host wins so direct adapter callers cannot produce a valid signature\n// scope for one region while forwarding to another.\nfunc signingRegion(req *http.Request, upstream *url.URL) string {\n\tif upstream != nil {","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/proxy/providers/bedrock/routing.go#L330-L366","documentation":"Error \"bedrock requested region %q does not match endpoint region %q\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at proxy/providers/bedrock/routing.go:348 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the requested region match the endpoint region."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}