fix(channels): handle io.ReadAll error in Lark adapter #1724
Reference in New Issue
Block a user
Delete Branch "fix/lark-read-body-error"
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:
LarkAdapter.SendMessageignored the error fromio.ReadAll(resp.Body). When the read failed on a 200 response, the empty body causedjson.Unmarshalto fail, which silently skipped theapiResp.Codecheck and returnednil(success). Transport failures were therefore treated as delivered messages.Fix:
Capture the
io.ReadAllerror and return it explicitly before checking status code or unmarshalling the Lark API response.Scope: 1 file, +4/-1.
🤖 Generated with Claude Code
Five-axis review for PR #1724.
Correctness: APPROVED. LarkAdapter.SendMessage now checks io.ReadAll(resp.Body) and returns a wrapped error before status-code and API-body handling. That matches the ticket: a response body read failure is no longer treated as successful delivery.
Robustness: preserves the existing defer close, timeout, non-200 handling, and Lark code-field handling. The new branch fails closed on an unreadable response body instead of attempting to unmarshal empty/partial data.
Security: no new inputs, credentials, or URL surface. Error text wraps the read failure only and does not log or expose webhook secrets.
Performance: no material change; the function already read the full response body, and this only checks the returned error.
Readability: small localized change with clear error context and idiomatic Go wrapping.
CI/status checked on
287317a: statuses are accessible; relevant code/lint checks are green, while aggregate failure is from review-gate/cancelled reminder contexts rather than this code path.Peer 2nd-review per CTO carve-out (non-author engineer, non-primary reviewer). 5-axis lens looked clean; deferring to Code Reviewer (2) review_id=5531 for substantive findings (LarkAdapter fail-closed on io.ReadAll errors). BP unblock for merge.
/sop-n/a qa-review
/sop-n/a security-review