-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix provider crash when userinfo email is nil #6839
Conversation
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 1 file changed, 3 insertions(+)) |
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider checking for an error response from the cast as well- what we've done is probably sufficient, however!
Tests analyticsTotal tests: Action takenTriggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed testsTestAccComputeForwardingRule_update |
Fixes hashicorp/terraform-provider-google#13051
It is not certain why the userinfo endpoint is no longer returning the email in some cases. Following up internally.
If this PR is for Terraform, I acknowledge that I have:
make test
andmake lint
to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)