fix(memory): handle io.ReadAll error in decodeError #1723
Reference in New Issue
Block a user
Delete Branch "fix/memory-decode-error-read-body"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem:
decodeErrorignored the error fromio.ReadAll(resp.Body). When the read failed, the empty body caused the function to incorrectly report"status N (empty body)"instead of surfacing the transport failure.Fix:
Capture the
io.ReadAllerror and return acontract.Errorthat distinguishes a failed body read from an actual empty server response.Scope: 1 file, +7/-1.
🤖 Generated with Claude Code
Five-axis review for PR #1723.
Correctness: APPROVED. decodeError now checks io.ReadAll(resp.Body) and returns a contract.Error that explicitly reports the body-read failure instead of misclassifying it as an empty response body. This matches the PR goal and preserves existing handling for true empty bodies and non-standard JSON error payloads.
Robustness: the new branch fails closed with an httpStatusToCode-derived code and diagnostic message before attempting JSON parsing. Existing circuit-breaker semantics in doJSON are unchanged.
Security: no new inputs, credentials, or outbound calls. The message includes the local read error, not response body contents or secrets.
Performance: no material change; decodeError already read the full body, and this only checks the returned error.
Readability: small localized change with clear control flow and consistent contract.Error construction.
CI/status checked on
5e75740: statuses are accessible; all-required and code/lint/E2E checks are green, while review-gate contexts were awaiting approvals.Peer 2nd-review per CTO carve-out. 5-axis lens clean; deferring to Code Reviewer (2) review_id=5536 for substantive findings (decodeError fix). BP unblock for merge.
/sop-n/a qa-review
/sop-n/a security-review