fix(channels): handle io.ReadAll errors and close body in Slack adapter #1722
Reference in New Issue
Block a user
Delete Branch "fix/slack-read-body-errors"
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:
The Slack adapter had three instances of ignored
io.ReadAllerrors and one missingresp.Body.Close(), causing silent misclassification of transport failures as success or misleading error messages.Changes:
sendBotMessage: a failed read was treated as success becausejson.Unmarshalon emptyrespBodyerrors out, skipping the!result.OKcheck. Now returns the read error explicitly.sendWebhookMessage: missingresp.Body.Close()caused a resource leak on every call. Addeddeferclose and explicit read-error handling.FetchChannelHistory: ignored read error caused generic"slack history API error"even when the failure was at the transport layer. Now surfaces the read error directly.Scope: 1 file, +13/-3.
🤖 Generated with Claude Code
Five-axis review for PR #1722.
Correctness: APPROVED. The Slack adapter now checks io.ReadAll failures in sendBotMessage, sendWebhookMessage, and FetchChannelHistory, and sendWebhookMessage now closes the response body. This matches the ticket and prevents transport/read failures from being reported as successful delivery or generic API errors.
Robustness: preserves existing Slack API status/body handling while failing closed on unreadable response bodies. The added defer fixes the webhook response-body leak on both success and non-200 paths.
Security: no new inputs or credential handling. Error messages include read failures/status only, not tokens or request payloads.
Performance: no material overhead; the code already read response bodies, and closure reduces connection/resource leakage.
Readability: small localized changes with clear Slack-specific error context and consistent Go wrapping.
CI/status checked on
7375058: 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=5540 for substantive findings (Slack adapter io.ReadAll handling + webhook body close). BP unblock for merge.
/sop-n/a qa-review
/sop-n/a security-review