From 0f64ef7e1c9e373e816d095115b41316c9b84fb8 Mon Sep 17 00:00:00 2001 From: Katy Moe Date: Fri, 2 Sep 2022 10:54:32 +0100 Subject: [PATCH 1/2] schema: fix unknown value validation bug The validate function should exit early in the case that a value is not wholly known. This is the intent of the comment and earlier code in this file - however, subsequent refactors introduced a bug in which one aspect of validation was run for unknown values: deprecation warnings. Deprecation warnings for known values are generated by validateType lower down. This fix ensures that deprecation warnings are not shown for unknown values, while still ensuring we exit validation early for all unknown values. --- helper/schema/schema.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 22fe196b775..5b398fd1604 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -1735,15 +1735,7 @@ func (m schemaMap) validate( // The SDK has to allow the unknown value through initially, so that // Required fields set via an interpolated value are accepted. if !isWhollyKnown(raw) { - if schema.Deprecated != "" { - return append(diags, diag.Diagnostic{ - Severity: diag.Warning, - Summary: "Argument is deprecated", - Detail: schema.Deprecated, - AttributePath: path, - }) - } - return diags + return nil } err = validateConflictingAttributes(k, schema, c) From db2b35bea496075a3ffaa0bd46e4bbf8a97f478e Mon Sep 17 00:00:00 2001 From: Katy Moe Date: Fri, 2 Sep 2022 11:03:22 +0100 Subject: [PATCH 2/2] unknown + deprecated should not generate diag --- helper/schema/schema_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 0dec6bb27eb..6bd9e46733e 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -5792,10 +5792,7 @@ func TestSchemaMap_Validate(t *testing.T) { Config: map[string]interface{}{ "old_news": hcl2shim.UnknownVariableValue, }, - - Warnings: []string{ - "Warning: Argument is deprecated: please use 'new_news' instead", - }, + Err: false, }, "Required sub-resource field": {