{"record":{"id":"bedc5ec11d988f6b","repo":"JuliusBrussee/caveman","slug":"rewriter-build-request-w","errorCode":null,"errorMessage":"rewriter: build request: %w","messagePattern":"rewriter: build request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rewriter/provider.go","lineNumber":179,"sourceCode":"// a caller-set temperature. The reasoning families (gpt-5*, o1/o3/o4*) do not.\nfunc openAIAcceptsTemperature(model string) bool {\n\tname := strings.ToLower(strings.TrimSpace(model))\n\tfor _, prefix := range []string{\"gpt-5\", \"o1\", \"o3\", \"o4\"} {\n\t\tif name == prefix || strings.HasPrefix(name, prefix+\"-\") || strings.HasPrefix(name, prefix+\".\") {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc (c *Client) do(ctx context.Context, endpoint string, body map[string]any, headers map[string]string) ([]byte, error) {\n\tencoded, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rewriter: encode request: %w\", err)\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewReader(encoded))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rewriter: build request: %w\", err)\n\t}\n\treq.Header.Set(\"content-type\", \"application/json\")\n\tfor key, value := range headers {\n\t\treq.Header.Set(key, value)\n\t}\n\n\tresp, err := c.doer(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rewriter: %s: %w\", endpoint, err)\n\t}\n\t// An injected doer is caller code; a nil response or body must surface as an\n\t// error rather than a panic inside the proxy hot path.\n\tif resp == nil {\n\t\treturn nil, fmt.Errorf(\"rewriter: %s: nil response\", endpoint)\n\t}\n\tif resp.Body == nil {\n\t\tresp.Body = http.NoBody\n\t}","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/rewriter/provider.go#L161-L197","documentation":"http.NewRequestWithContext refused to build the POST request for the rewriter provider — almost always because the endpoint URL string is malformed or unsupported as a request target. This is a configuration-level fault in the endpoint passed to Client.do, before any network activity.","triggerScenarios":"Thrown at rewriter/provider.go:179 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the rewriter provider endpoint URL so it is a valid absolute http(s) URL","Check the provider base-URL configuration for typos or missing scheme"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}