From c19118f9e057443fb9a7740baa613a80d1fe1025 Mon Sep 17 00:00:00 2001 From: Aviral Jain Date: Tue, 2 Jul 2024 14:05:16 +0530 Subject: [PATCH] skip check evaluation when context is not prepared successfully (#35408) --- internal/moduletest/eval_context.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/moduletest/eval_context.go b/internal/moduletest/eval_context.go index aff007a890..fe4fb3be62 100644 --- a/internal/moduletest/eval_context.go +++ b/internal/moduletest/eval_context.go @@ -94,6 +94,14 @@ func (ec *EvalContext) Evaluate() (Status, cty.Value, tfdiags.Diagnostics) { hclCtx, moreDiags := scope.EvalContext(refs) ruleDiags = ruleDiags.Append(moreDiags) + if moreDiags.HasErrors() { + // if we can't evaluate the context properly, we can't evaulate the rule + // we add the diagnostics to the main diags and continue to the next rule + log.Printf("[TRACE] EvalContext.Evaluate: check rule %d for %s is invalid, could not evalaute the context, so cannot evaluate it", i, ec.run.Addr()) + status = status.Merge(Error) + diags = diags.Append(ruleDiags) + continue + } errorMessage, moreDiags := lang.EvalCheckErrorMessage(rule.ErrorMessage, hclCtx) ruleDiags = ruleDiags.Append(moreDiags)