From 936f597ba121f8de168e031f0c2f6ca60dd1d780 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 25 Feb 2021 09:53:57 -0500 Subject: [PATCH] check errors before using configSnap configSnap may be nil if there are errors loading it from the plan file. --- backend/local/backend_local.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/local/backend_local.go b/backend/local/backend_local.go index 6276fa5cf3..6287d43fa4 100644 --- a/backend/local/backend_local.go +++ b/backend/local/backend_local.go @@ -95,6 +95,10 @@ func (b *Local) context(op *backend.Operation) (*terraform.Context, *configload. } log.Printf("[TRACE] backend/local: building context from plan file") tfCtx, configSnap, ctxDiags = b.contextFromPlanFile(op.PlanFile, opts, stateMeta) + if ctxDiags.HasErrors() { + return nil, nil, nil, ctxDiags + } + // Write sources into the cache of the main loader so that they are // available if we need to generate diagnostic message snippets. op.ConfigLoader.ImportSourcesFromSnapshot(configSnap)