{"record":{"id":"e000788abc0e4e5e","repo":"caddyserver/caddy","slug":"error-reading-response-body-v","errorCode":null,"errorMessage":"error reading response body: %v","messagePattern":"error reading response body: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddytls/certmanagers.go","lineNumber":173,"sourceCode":"\t\treturn nil, err\n\t}\n\n\tresp, err := http.DefaultClient.Do(req) //nolint:gosec // SSRF false positive... request URI comes from config\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode == http.StatusNoContent {\n\t\t// endpoint is not managing certs for this handshake\n\t\treturn nil, nil\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"got HTTP %d\", resp.StatusCode)\n\t}\n\n\tbodyBytes, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading response body: %v\", err)\n\t}\n\n\tcert, err := tlsCertFromCertAndKeyPEMBundle(bodyBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &cert, nil\n}\n\n// UnmarshalCaddyfile deserializes Caddyfile tokens into ts.\n//\n//\t... http <url>\nfunc (hcg *HTTPCertGetter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {\n\td.Next() // consume cert manager name\n\n\tif !d.NextArg() {\n\t\treturn d.ArgErr()","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddytls/certmanagers.go#L155-L191","documentation":"Returned by HTTPCertGetter.GetCertificate when the response body from the certificate endpoint returned HTTP 200 but io.ReadAll failed mid-transfer. This is a transport-level failure (connection reset, timeout, truncated chunked encoding), not a certificate-format problem.","triggerScenarios":"The remote cert server closes the connection before sending the full body; a proxy between Caddy and the endpoint times out; keep-alive races or TLS renegotiation on the upstream connection; very large bundles hitting a proxy's response size limit mid-stream.","commonSituations":"Flaky upstream network, misbehaving load balancer with a short proxy_read_timeout, or the cert service crashing while streaming the response. Note this uses http.DefaultClient, which has no overall timeout, so mid-body failures usually come from connection resets rather than client timeouts.","solutions":["Retry the handshake/request: transient network errors are the most common cause","Check upstream and proxy logs for connection resets or read timeouts at the same timestamp","Raise proxy read timeouts if the bundle is large or generation is slow","If persistent, capture a tcpdump of one request to see where the stream is truncated"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Serve the bundle with Content-Length set so truncation is detectable and rare","Keep proxy read timeouts generously above bundle generation time","Monitor upstream connection-reset rates; this error is almost always transport-layer"],"tags":["caddy","tls","http","network","io"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}