From 677ffd1f6072a9dbb47e4639130aa88b724dc253 Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 16 Nov 2022 13:02:07 -0800 Subject: [PATCH] Fix provider crash when userinfo email is nil (#6839) (#1130) Fixes https://github.com/hashicorp/terraform-provider-google/issues/13051 Signed-off-by: Modular Magician Signed-off-by: Modular Magician --- converters/google/resources/utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/converters/google/resources/utils.go b/converters/google/resources/utils.go index 0005cec2c..c04c93bcf 100644 --- a/converters/google/resources/utils.go +++ b/converters/google/resources/utils.go @@ -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 }