Skip to content

Commit

Permalink
[bug] Quick fix for handling non 200 status codes when loading specs …
Browse files Browse the repository at this point in the history
…from URI (#1695)

* Quick fix for handling non 200 status codes when loading specs from URI

Go http client already handles 3xx responses for us

* note
  • Loading branch information
hedge-sparrow authored Nov 25, 2024
1 parent 9f5f063 commit ecc92b1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/supportbundle/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ func loadSpecFromURL(arg string) ([]byte, error) {
}
return nil, errors.Wrap(err, "execute request")
}

// handle non 2xx http statuses
// redirects appear to already be handled by the go http client
// TODO: handle potential for redirect loops breaking this?
if resp.StatusCode != 200 {
return nil, errors.New("request returned non 200 response")
}

defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
Expand Down

0 comments on commit ecc92b1

Please sign in to comment.