github: Handle empty x-ratelimit-remaining header

Signed-off-by: unilock <unilock@fennet.rentals>
This commit is contained in:
unilock 2023-10-26 10:56:08 -04:00
parent 3859b37267
commit 72afdee4d8

View File

@ -37,9 +37,15 @@ func (c *ghApiClient) makeGet(url string) (*http.Response, error) {
return nil, err
}
ratelimit, err := strconv.Atoi(resp.Header.Get("x-ratelimit-remaining"))
if err != nil {
return nil, err
// TODO: there is likely a better way to do this
ratelimit := 999
ratelimit_header := resp.Header.Get("x-ratelimit-remaining")
if ratelimit_header != "" {
ratelimit, err = strconv.Atoi(ratelimit_header)
if err != nil {
return nil, err
}
}
if resp.StatusCode == 403 && ratelimit == 0 {