Skip to content

Commit 9b51975

Browse files
modular-magicianc2thorn
authored andcommitted
Fix provider crash when userinfo email is nil (#6839) (#4892)
Fixes hashicorp/terraform-provider-google#13051 Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent f58a056 commit 9b51975

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

.changelog/6839.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
provider: fixed a crash during provider authentication for certain environments
3+
```

google-beta/utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ func GetCurrentUserEmail(config *Config, userAgent string) (string, error) {
508508
if err != nil {
509509
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)
510510
}
511+
if res["email"] == nil {
512+
return "", fmt.Errorf("error retrieving email from userinfo. email was nil in the response.")
513+
}
511514
return res["email"].(string), nil
512515
}
513516

0 commit comments

Comments
 (0)