Skip to content

Commit 297972e

Browse files
committed
incorrect validateCount function was hiding diags
The validateCount function was probably implemented incorrectly to hide some other evaluation bug. There shouldn't be any reason to disregard diagnostics because the value is unknown.
1 parent 04aee4e commit 297972e

2 files changed

Lines changed: 2 additions & 17 deletions

File tree

internal/terraform/context_plan_ephemeral_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ resource "test_object" "test" {
179179
}
180180
`,
181181
},
182-
expectPlanDiagnostics: func(m *configs.Config) (diags tfdiags.Diagnostics) {
182+
expectValidateDiagnostics: func(m *configs.Config) (diags tfdiags.Diagnostics) {
183183
return diags.Append(&hcl.Diagnostic{
184184
Severity: hcl.DiagError,
185185
Summary: "Invalid count argument",

internal/terraform/node_resource_validate.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func (n *NodeValidatableResource) validateResource(ctx EvalContext) tfdiags.Diag
300300

301301
// Basic type-checking of the count argument. More complete validation
302302
// of this will happen when we DynamicExpand during the plan walk.
303-
countDiags := validateCount(ctx, n.Config.Count)
303+
_, countDiags := evaluateCountExpressionValue(n.Config.Count, ctx)
304304
diags = diags.Append(countDiags)
305305

306306
case n.Config.ForEach != nil:
@@ -727,21 +727,6 @@ func (n *NodeValidatableResource) validateConfigGen(ctx EvalContext) tfdiags.Dia
727727
return diags
728728
}
729729

730-
func validateCount(ctx EvalContext, expr hcl.Expression) (diags tfdiags.Diagnostics) {
731-
val, countDiags := evaluateCountExpressionValue(expr, ctx)
732-
// If the value isn't known then that's the best we can do for now, but
733-
// we'll check more thoroughly during the plan walk
734-
if !val.IsKnown() {
735-
return diags
736-
}
737-
738-
if countDiags.HasErrors() {
739-
diags = diags.Append(countDiags)
740-
}
741-
742-
return diags
743-
}
744-
745730
func validateDependsOn(ctx EvalContext, dependsOn []hcl.Traversal) (diags tfdiags.Diagnostics) {
746731
for _, traversal := range dependsOn {
747732
ref, refDiags := addrs.ParseRef(traversal)

0 commit comments

Comments
 (0)