From ad78ba06ea60df10e643b6cc771af58d98ef5955 Mon Sep 17 00:00:00 2001 From: ex-takashima Date: Thu, 7 May 2026 16:41:19 +0900 Subject: [PATCH] fix(line): close HTTP response body from WithHttpInfo calls Fix bodyclose linter errors by ensuring resp.Body is closed after all *WithHttpInfo SDK calls. Co-Authored-By: Claude Opus 4.6 (1M context) --- pkg/channels/line/line.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/channels/line/line.go b/pkg/channels/line/line.go index 6cc9f0cd9..61d2ee18f 100644 --- a/pkg/channels/line/line.go +++ b/pkg/channels/line/line.go @@ -459,10 +459,13 @@ func (c *LINEChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]stri if entry, ok := c.replyTokens.LoadAndDelete(msg.ChatID); ok { tokenEntry := entry.(replyTokenEntry) if time.Since(tokenEntry.timestamp) < lineReplyTokenMaxAge { - _, _, err := c.client.WithContext(ctx).ReplyMessageWithHttpInfo(&messaging_api.ReplyMessageRequest{ + resp, _, err := c.client.WithContext(ctx).ReplyMessageWithHttpInfo(&messaging_api.ReplyMessageRequest{ ReplyToken: tokenEntry.token, Messages: []messaging_api.MessageInterface{&textMsg}, }) + if resp != nil && resp.Body != nil { + resp.Body.Close() + } if err == nil { logger.DebugCF("line", "Message sent via Reply API", map[string]any{ "chat_id": msg.ChatID, @@ -566,6 +569,9 @@ func (c *LINEChannel) StartTyping(ctx context.Context, chatID string) (func(), e // classifySDKError maps an SDK HTTP response to the project's sentinel errors. func classifySDKError(resp *http.Response, err error) error { + if resp != nil && resp.Body != nil { + resp.Body.Close() + } if err == nil { return nil }