OpenNHP/opennhp · error
failed to read response body
Error message
failed to read response body: %w
What it means
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.
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
Example fix
// before
body, err := io.ReadAll(resp.Body)
// after
body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
if err != nil {
return nil, retryOrWrap(err, "failed to read response body")
} Defensive patterns
Strategy: retry
Try / catch
ev, err := engine.GetEvidenceWithCCUrl()
if err != nil {
if strings.Contains(err.Error(), "failed to read response body") {
time.Sleep(500*time.Millisecond)
ev, err = engine.GetEvidenceWithCCUrl() // bounded retry
}
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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).
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- could not read response body
- failed to read HRK data
- failed to download ztdo
- could not send https request
- failed to download HRK
AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07).
Data as JSON: /api/errors/5821a39074412f8a.
Report an issue: GitHub.
Appendix: source
Thrown at nhp/core/wasm/engine/host.go:53
}
func GetEvidenceWithCCUrl() ([]byte, error) {
client := &http.Client{Timeout: 3 * time.Second}
resp, err := client.Get(confidentialContainerEvidenceUrl)
if err != nil {
return nil, fmt.Errorf("http request failed: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
var buf bytes.Buffer
w := zlib.NewWriter(&buf)
_, err = w.Write(body)
w.Close()
if err != nil {
return nil, fmt.Errorf("failed to compress response body: %w", err)
}
compressedBody := buf.Bytes()
return compressedBody, nil
}
func GetEvidenceWithAgentUuid() ([]byte, error) {
agentUniqueId, err := CalculateAgentUniqueId()
if err != nil {View on GitHub (pinned to 6e04ca5ff0)