{"record":{"id":"c8659c4142f5a2a4","repo":"JuliusBrussee/caveman","slug":"bedrock-base-url-invalid-w","errorCode":null,"errorMessage":"bedrock base url invalid: %w","messagePattern":"bedrock base url invalid: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/providers/bedrock/routing.go","lineNumber":154,"sourceCode":")\n\n// ResolveUpstreamURL validates the endpoint kind, region, action, and model\n// resource, then resolves one of two explicit Bedrock surfaces:\n//\n//   - Runtime: /bedrock/model/... -> bedrock-runtime.../model/...\n//   - Mantle:  /bedrock/anthropic/v1/messages -> bedrock-mantle.../anthropic/...\n//\n// Mantle stays deployment-opt-in because its IAM service, model coverage,\n// quotas, features, stream wire, and AWS invocation-logging support differ from\n// Runtime. Both surfaces remain provider=bedrock in telemetry.\nfunc (a Adapter) ResolveUpstreamURL(ctx context.Context, req *http.Request, route providers.RouteContext) (*url.URL, error) {\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(\"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)","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/providers/bedrock/routing.go#L136-L172","documentation":"The Bedrock adapter parses its configured base URL (adapter BaseURL or route.BaseURL) with url.Parse before routing and signing. This error wraps the underlying parse failure — the configured endpoint is not a valid URL at all, so no upstream can be resolved.","triggerScenarios":"A route or adapter configured with a base URL that url.Parse rejects — e.g. containing control characters, an invalid scheme like \"hxxp://\", or a malformed percent-escape such as https://bedrock-runtime.us-east-1.amazonaws.com/%zz.","commonSituations":"Typo in caveman.yaml route base_url; pasting an endpoint with stray whitespace or quotes; a templated/interpolated URL where a variable expanded to something containing \"{\" \"}\" or spaces.","solutions":["Fix the configured base URL so it is a valid absolute https:// URL (no stray characters, quotes, or bad percent-escapes).","Check route.BaseURL in caveman.yaml first (it overrides the adapter default), then the adapter-level BaseURL.","Log/print the exact string being parsed — url.Parse errors usually point at the offending component."],"exampleFix":"// before\nbase_url: https://bedrock-runtime.us-east-1.amazonaws.com/%zz\n// after\nbase_url: https://bedrock-runtime.us-east-1.amazonaws.com","handlingStrategy":"validation","validationCode":"base, err := url.Parse(cfg.BaseURL)\nif err != nil {\n\treturn fmt.Errorf(\"invalid bedrock base_url %q: %w\", cfg.BaseURL, err)\n}\nif base.Scheme != \"https\" || base.Host == \"\" {\n\treturn fmt.Errorf(\"bedrock base_url %q must be an absolute https URL\", cfg.BaseURL)\n}","typeGuard":null,"tryCatchPattern":"// Go\nif _, err := adapter.ResolveUpstreamURL(ctx, req, route); err != nil {\n\tvar uerr *url.Error\n\tif errors.As(err, &uerr) && strings.Contains(err.Error(), \"base url invalid\") {\n\t\t// fail fast: fix configuration, do not retry\n\t\treturn fmt.Errorf(\"configuration error: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Validate base_url at config-load time, not at request time.","Avoid templating URLs by string interpolation; escape or validate expansions.","Strip quotes/whitespace when pasting endpoints into caveman.yaml."],"tags":["bedrock","aws","url","config","parsing"],"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"}