JuliusBrussee/caveman · error

bedrock requested region %q does not match endpoint region %

Error message

bedrock requested region %q does not match endpoint region %q

What it means

Error "bedrock requested region %q does not match endpoint region %q" thrown in JuliusBrussee/caveman.

Source

Thrown at proxy/providers/bedrock/routing.go:348

	}
	idx := strings.LastIndex(rest, "/")
	if idx <= 0 || idx == len(rest)-1 {
		return "", ""
	}
	return rest[:idx], rest[idx+1:]
}

// resolveRegion keeps routing, allowlisting, and signing on one region. A
// recognized endpoint host is authoritative; a contradictory client header is
// rejected rather than validating one region and dialing another.
func resolveRegion(req *http.Request, base *url.URL) (string, error) {
	requested := strings.TrimSpace(req.Header.Get("x-cave-aws-region"))
	hostRegion := ""
	if base != nil {
		hostRegion = regionFromHost(base.Hostname())
	}
	if requested != "" && hostRegion != "" && requested != hostRegion {
		return "", fmt.Errorf("bedrock requested region %q does not match endpoint region %q", requested, hostRegion)
	}
	if hostRegion != "" {
		return hostRegion, nil
	}
	if requested != "" {
		return requested, nil
	}
	if r := regionFromHost(req.Header.Get("x-cave-bedrock-host")); r != "" {
		return r, nil
	}
	return env.String("CAVE_BEDROCK_REGION", "us-east-1"), nil
}

// signingRegion picks the AWS region the SigV4 scope is built for. The resolved
// upstream host wins so direct adapter callers cannot produce a valid signature
// scope for one region while forwarding to another.
func signingRegion(req *http.Request, upstream *url.URL) string {
	if upstream != nil {

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Make the requested region match the endpoint region.

When it happens

Trigger: Thrown at proxy/providers/bedrock/routing.go:348 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/2a98e2b0d34e4930. Report an issue: GitHub.