diff --git a/internal/configs/configschema/coerce_value.go b/internal/configs/configschema/coerce_value.go index fec6b35118..9c47257d45 100644 --- a/internal/configs/configschema/coerce_value.go +++ b/internal/configs/configschema/coerce_value.go @@ -67,8 +67,10 @@ func (b *Block) coerceValue(in cty.Value, path cty.Path) (cty.Value, error) { val = in.GetAttr(name) case attrS.Computed || attrS.Optional: val = cty.NullVal(attrType) - default: + case attrS.Required: return cty.UnknownVal(impliedType), path.NewErrorf("attribute %q is required", name) + default: + return cty.UnknownVal(impliedType), path.NewErrorf("attribute %q has none of required, optional, or computed set", name) } val, err := convert.Convert(val, attrConvType) diff --git a/internal/configs/configschema/coerce_value_test.go b/internal/configs/configschema/coerce_value_test.go index 3deeff719b..697724c6c1 100644 --- a/internal/configs/configschema/coerce_value_test.go +++ b/internal/configs/configschema/coerce_value_test.go @@ -446,6 +446,20 @@ func TestCoerceValue(t *testing.T) { }), ``, }, + "omitted attribute requirements": { + &Block{ + Attributes: map[string]*Attribute{ + "foo": { + Type: cty.String, + }, + }, + }, + cty.EmptyObjectVal, + cty.ObjectVal(map[string]cty.Value{ + "foo": cty.UnknownVal(cty.String), + }), + `attribute "foo" has none of required, optional, or computed set`, + }, "dynamic value attributes": { &Block{ BlockTypes: map[string]*NestedBlock{