diff --git a/configs/configschema/coerce_value.go b/configs/configschema/coerce_value.go index 23a48e1be..41a533745 100644 --- a/configs/configschema/coerce_value.go +++ b/configs/configschema/coerce_value.go @@ -8,9 +8,7 @@ import ( ) // CoerceValue attempts to force the given value to conform to the type -// implied by the receiever, while also applying the same validation and -// transformation rules that would be applied by the decoder specification -// returned by method DecoderSpec. +// implied by the receiever. // // This is useful in situations where a configuration must be derived from // an already-decoded value. It is always better to decode directly from @@ -83,16 +81,8 @@ func (b *Block) coerceValue(in cty.Value, path cty.Path) (cty.Value, error) { if err != nil { return cty.UnknownVal(b.ImpliedType()), err } - case blockS.MinItems != 1 && blockS.MaxItems != 1: - if blockS.Nesting == NestingGroup { - attrs[typeName] = blockS.EmptyValue() - } else { - attrs[typeName] = cty.NullVal(blockS.ImpliedType()) - } default: - // We use the word "attribute" here because we're talking about - // the cty sense of that word rather than the HCL sense. - return cty.UnknownVal(b.ImpliedType()), path.NewErrorf("attribute %q is required", typeName) + attrs[typeName] = blockS.EmptyValue() } case NestingList: diff --git a/configs/configschema/coerce_value_test.go b/configs/configschema/coerce_value_test.go index 084107878..974dfdd35 100644 --- a/configs/configschema/coerce_value_test.go +++ b/configs/configschema/coerce_value_test.go @@ -288,8 +288,10 @@ func TestCoerceValue(t *testing.T) { }, }, cty.EmptyObjectVal, - cty.DynamicVal, - `attribute "foo" is required`, + cty.ObjectVal(map[string]cty.Value{ + "foo": cty.NullVal(cty.EmptyObject), + }), + ``, }, "unknown nested list": { &Block{