From 711b290d83bec1a010be5cebbf511aebd32572a5 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 31 Jul 2020 11:53:33 -0700 Subject: [PATCH] Set context early on in LoadAndValidate to prevent NPE (#3800) (#2321) Signed-off-by: Modular Magician --- .changelog/3800.txt | 3 +++ google-beta/config.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .changelog/3800.txt diff --git a/.changelog/3800.txt b/.changelog/3800.txt new file mode 100644 index 0000000000..f181f5fcf5 --- /dev/null +++ b/.changelog/3800.txt @@ -0,0 +1,3 @@ +```release-note:bug +Fixed crash due to nil context when loading credentials +``` diff --git a/google-beta/config.go b/google-beta/config.go index e8f51012f9..cf5a5eaec3 100644 --- a/google-beta/config.go +++ b/google-beta/config.go @@ -314,6 +314,8 @@ func (c *Config) LoadAndValidate(ctx context.Context) error { c.Scopes = DefaultClientScopes } + c.context = ctx + tokenSource, err := c.getTokenSource(c.Scopes) if err != nil { return err @@ -345,7 +347,6 @@ func (c *Config) LoadAndValidate(ctx context.Context) error { userAgent := fmt.Sprintf("%s %s", tfUserAgent, providerVersion) c.client = client - c.context = ctx c.userAgent = userAgent // This base path and some others below need the version and possibly more of the path