{"record":{"id":"a3224109cbc1b156","repo":"JuliusBrussee/caveman","slug":"rewriter-s-w","errorCode":null,"errorMessage":"rewriter: %s: %w","messagePattern":"rewriter: (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rewriter/provider.go","lineNumber":188,"sourceCode":"}\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}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode < 200 || resp.StatusCode > 299 {\n\t\tdetail, _ := io.ReadAll(io.LimitReader(resp.Body, maxErrorBody))\n\t\treturn nil, fmt.Errorf(\"rewriter: %s: status %d: %s\", endpoint, resp.StatusCode, strings.TrimSpace(string(detail)))\n\t}\n\traw, err := io.ReadAll(io.LimitReader(resp.Body, maxProviderResponseBody+1))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rewriter: read response: %w\", err)","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/rewriter/provider.go#L170-L206","documentation":"Client.do's injected doer returned a transport-level error while executing the rewriter provider request (connection refused, timeout, DNS failure, TLS error). The message wraps the underlying error and names the endpoint so transport faults are distinguishable from decode or status errors.","triggerScenarios":"Thrown at rewriter/provider.go:188 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry with backoff; transient network failures are expected","Check network reachability and TLS configuration for the provider endpoint","Treat persistent failure as provider unavailability and skip the rewrite (the gate records api_error)"],"exampleFix":null,"handlingStrategy":"retry","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"}