BRUHItsABunny/go-android-firebase

bug: index out of range when response code is not 200

Opened this issue · 0 comments

Program crashed with an error index out of range on this line:

expiresIn, _ := strconv.Atoi(result.AuthToken.Expiration[:len(result.AuthToken.Expiration)-1])

My request payload was invalid and firebase API returned 40x code and no err (it's the behavior of client.Do). That's why we have to check resp.StatusCode after err != nil and return err if status is not http.StatusOK

resp, err := c.Client.Do(req)
if err != nil {
return nil, fmt.Errorf("c.Client.Do: %w", err)
}