{"record":{"id":"5821a39074412f8a","repo":"OpenNHP/opennhp","slug":"failed-to-read-response-body-w","errorCode":null,"errorMessage":"failed to read response body: %w","messagePattern":"failed to read response body: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/core/wasm/engine/host.go","lineNumber":53,"sourceCode":"}\n\nfunc GetEvidenceWithCCUrl() ([]byte, error) {\n\tclient := &http.Client{Timeout: 3 * time.Second}\n\n\tresp, err := client.Get(confidentialContainerEvidenceUrl)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"http request failed: %w\", err)\n\t}\n\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"unexpected status code: %d\", resp.StatusCode)\n\t}\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read response body: %w\", err)\n\t}\n\n\tvar buf bytes.Buffer\n\tw := zlib.NewWriter(&buf)\n\t_, err = w.Write(body)\n\tw.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to compress response body: %w\", err)\n\t}\n\n\tcompressedBody := buf.Bytes()\n\n\treturn compressedBody, nil\n}\n\nfunc GetEvidenceWithAgentUuid() ([]byte, error) {\n\tagentUniqueId, err := CalculateAgentUniqueId()\n\tif err != nil {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/core/wasm/engine/host.go#L35-L71","documentation":"Raised by GetEvidenceWithCCUrl after a 200 response: io.ReadAll of the response body failed mid-transfer. The connection to the confidential-container evidence endpoint broke while streaming the body, so the raw evidence bytes could not be collected for compression and return to the WASM guest.","triggerScenarios":"AAA accepted the connection, sent 200, then closed early or the stream was interrupted mid-read (AAA crash while generating the TEE report, container OOM-kill, socket timeout).","commonSituations":"Attestation agent dying mid-request under memory pressure; TCP reset by a sidecar/proxy; large evidence payloads over an unstable link (rare for localhost, common through proxies).","solutions":["Retry GetEvidenceWithCCUrl — transient resets are common while AAA is warming up","Check AAA container logs/OOM events at the failure timestamp","Increase the http.Client timeout and/or add a retry with backoff around the whole call"],"exampleFix":"// before\nbody, err := io.ReadAll(resp.Body)\n// after\nbody, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))\nif err != nil {\n    return nil, retryOrWrap(err, \"failed to read response body\")\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"ev, err := engine.GetEvidenceWithCCUrl()\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to read response body\") {\n        time.Sleep(500*time.Millisecond)\n        ev, err = engine.GetEvidenceWithCCUrl() // bounded retry\n    }\n}","preventionTips":["Monitor AAA container for OOM kills/crashes","Keep evidence payloads small and read with io.LimitReader","Use localhost directly (avoid proxies) for the AAA endpoint"],"tags":["http","network","io"],"backgroundTag":"file-read-failed","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}