Skip to content

Commit

Permalink
Fix provider crash when userinfo email is nil (#6839)
Browse files Browse the repository at this point in the history
Fixes hashicorp/terraform-provider-google#13051

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Nov 16, 2022
1 parent 277179e commit 2070288
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions converters/google/resources/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ func GetCurrentUserEmail(config *Config, userAgent string) (string, error) {
if err != nil {
return "", fmt.Errorf("error retrieving userinfo for your provider credentials. have you enabled the 'https://www.googleapis.com/auth/userinfo.email' scope? error: %s", err)
}
if res["email"] == nil {
return "", fmt.Errorf("error retrieving email from userinfo. email was nil in the response.")
}
return res["email"].(string), nil
}

Expand Down

0 comments on commit 2070288

Please sign in to comment.