Skip to content

Commit

Permalink
fix: don't panic in client due to nil body (#4449)
Browse files Browse the repository at this point in the history
- introduced by #4366, we need to close the body only if there isn't an
error, else the body is nil and panics. Mentioned here
#4401 (comment)

Co-authored-by: frrist <[email protected]>
Co-authored-by: Walid Baruni <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2024
1 parent ad6d795 commit f3f318b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/publicapi/client/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ func (c *httpClient) write(ctx context.Context, verb, endpoint string, in apimod
}

_, resp, err := c.doRequest(ctx, verb, endpoint, r) //nolint:bodyclose // this is being closed
defer resp.Body.Close()
if err != nil {
return err
}
defer resp.Body.Close()

if resp.StatusCode == http.StatusUnauthorized {
return apimodels.ErrInvalidToken
Expand Down

0 comments on commit f3f318b

Please sign in to comment.