From d7f23f0beb8cbf09a313183d2f0cf3c723ecdf9e Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 17 Apr 2019 09:16:52 -0700 Subject: [PATCH] configs/configupgrade: Don't panic if analyzer fails Previously we were trying to access a field of the analysis object before checking if analysis produced errors. The analysis function usually returns a nil analysis on error, so this would result in a panic whenever that happened. Now we'll dereference the analysis object pointer only after checking for errors, so we'll get a chance to report the analysis error to the user. --- configs/configupgrade/upgrade.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/configupgrade/upgrade.go b/configs/configupgrade/upgrade.go index 85fd580f9..e2236a6c1 100644 --- a/configs/configupgrade/upgrade.go +++ b/configs/configupgrade/upgrade.go @@ -35,11 +35,11 @@ func (u *Upgrader) Upgrade(input ModuleSources, dir string) (ModuleSources, tfdi var diags tfdiags.Diagnostics an, err := u.analyze(input) - an.ModuleDir = dir if err != nil { diags = diags.Append(err) return ret, diags } + an.ModuleDir = dir for name, src := range input { ext := fileExt(name)