From c7bc22ed7948ff41548b08612b37b6bafb1317e8 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Wed, 21 Jan 2026 16:42:04 +0100 Subject: [PATCH] only unmark deep once for ValidateDeep --- internal/deprecation/deprecation.go | 3 +-- internal/lang/marks/marks.go | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/deprecation/deprecation.go b/internal/deprecation/deprecation.go index 956da60b47..7d96eda32a 100644 --- a/internal/deprecation/deprecation.go +++ b/internal/deprecation/deprecation.go @@ -50,8 +50,7 @@ func (d *Deprecations) Validate(value cty.Value, module addrs.Module, rng *hcl.R // ValidateDeep does the same as Validate but checks deeply nested deprecation marks as well. func (d *Deprecations) ValidateDeep(value cty.Value, module addrs.Module, rng *hcl.Range) (cty.Value, tfdiags.Diagnostics) { - deprecationMarks := marks.GetDeprecationMarksDeep(value) - notDeprecatedValue := marks.RemoveDeprecationMarksDeep(value) + notDeprecatedValue, deprecationMarks := marks.GetDeprecationMarksDeep(value) return notDeprecatedValue, d.deprecationMarksToDiagnostics(deprecationMarks, module, rng) } diff --git a/internal/lang/marks/marks.go b/internal/lang/marks/marks.go index 6421463f60..00a31dc335 100644 --- a/internal/lang/marks/marks.go +++ b/internal/lang/marks/marks.go @@ -70,9 +70,9 @@ func GetDeprecationMarks(val cty.Value) []DeprecationMark { // GetDeprecationMarksDeep returns all deprecation marks present on the given // cty.Value or any nested values. -func GetDeprecationMarksDeep(val cty.Value) []DeprecationMark { - _, marks := val.UnmarkDeep() - return FilterDeprecationMarks(marks) +func GetDeprecationMarksDeep(val cty.Value) (cty.Value, []DeprecationMark) { + unmarked, marks := val.UnmarkDeep() + return unmarked, FilterDeprecationMarks(marks) } // RemoveDeprecationMarks returns a copy of the given cty.Value with all