Skip to content

Commit 9668e2f

Browse files
e_forbesclaude
andcommitted
Close response body on error in ParseJSON
Matches the old client behaviour: when the status is >= 400 the body is fully read for the error message and then closed, allowing the underlying connection to be reused. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0483260 commit 9668e2f

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

internal/clients/gitlab/response.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
// - 2xx with non-JSON body → errors.New("parsing failed")
2020
func ParseJSON(resp *http.Response, dst any) error {
2121
if resp.StatusCode >= 400 {
22+
defer func() { _ = resp.Body.Close() }()
2223
var errResp struct {
2324
Message string `json:"message"`
2425
}

0 commit comments

Comments
 (0)