{"record":{"id":"151bfb0ddbcc869a","repo":"JuliusBrussee/caveman","slug":"rewriter-encode-request-w","errorCode":null,"errorMessage":"rewriter: encode request: %w","messagePattern":"rewriter: encode request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rewriter/provider.go","lineNumber":175,"sourceCode":"\t}, nil\n}\n\n// openAIAcceptsTemperature reports whether a chat-completions model still takes\n// 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)","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/rewriter/provider.go#L157-L193","documentation":"Client.do failed to JSON-marshal the request body map before sending it to the rewriter provider. This indicates a non-serializable value (NaN/Inf float, channel, func) was placed into the body — a programming bug in the caller building the request, not a provider-side fault.","triggerScenarios":"Thrown at rewriter/provider.go:175 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the request body map contains only JSON-serializable values","Sanitize or omit NaN/Inf floats before building the rewriter request"],"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"}