From 798adf3ce67de7e4acee723b8bd1cf1f88bbd4e1 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 29 May 2018 16:33:56 -0700 Subject: [PATCH] core: EvalSequence to handle EvalEarlyExitError An earlier commit today reworked this to handle non-fatal errors, which are returned "smuggled" as a special type of error to avoid changing the EvalNode interface. Unfortunately, that change then broke the _other_ special thing we smuggle through the error return path: early exit. Now we'll handle them both. This is not perfect because the early-exit path causes us to discard any warnings we've already collected, but it's more important that we bail early than retain warnings. --- terraform/eval_sequence.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/terraform/eval_sequence.go b/terraform/eval_sequence.go index ebc351bab..3485e4f14 100644 --- a/terraform/eval_sequence.go +++ b/terraform/eval_sequence.go @@ -18,6 +18,11 @@ func (n *EvalSequence) Eval(ctx EvalContext) (interface{}, error) { } if _, err := EvalRaw(n, ctx); err != nil { + if _, isEarlyExit := err.(EvalEarlyExitError); isEarlyExit { + // In this path we abort early, losing any non-error + // diagnostics we saw earlier. + return nil, err + } diags = diags.Append(err) if diags.HasErrors() { // Halt if we get some errors, but warnings are okay.