Skip to content

Commit

Permalink
fix: add check for empty response body
Browse files Browse the repository at this point in the history
This ensures that an empty response body, which is valid and present in
some endpoints.
  • Loading branch information
nobe4 committed May 19, 2024
1 parent 20b3d72 commit 702451a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/api/rest_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ func (c *RESTClient) DoWithContext(ctx context.Context, method string, path stri
return err
}

err = json.Unmarshal(b, &response)
if err != nil {
return err
if len(b) > 0 {
err = json.Unmarshal(b, &response)
if err != nil {
return err
}
}

return nil
Expand Down

0 comments on commit 702451a

Please sign in to comment.