diff --git a/cty/convert/mismatch_msg.go b/cty/convert/mismatch_msg.go index 0bd0cffa..5c1e114d 100644 --- a/cty/convert/mismatch_msg.go +++ b/cty/convert/mismatch_msg.go @@ -84,6 +84,10 @@ func mismatchMessageObjects(got, want cty.Type) string { continue } + if gotAty.Equals(wantAty) { + continue // exact match, so no problem + } + // We'll now try to convert these attributes in isolation and // see if we have a nested conversion error to report. // We'll try an unsafe conversion first, and then fall back on diff --git a/cty/convert/mismatch_msg_test.go b/cty/convert/mismatch_msg_test.go index 186fc99d..9963f5ff 100644 --- a/cty/convert/mismatch_msg_test.go +++ b/cty/convert/mismatch_msg_test.go @@ -104,6 +104,24 @@ func TestMismatchMessage(t *testing.T) { cty.List(cty.DynamicPseudoType), `all list elements must have the same type`, }, + { + cty.Object(map[string]cty.Type{ + "foo": cty.Bool, + "bar": cty.String, + "baz": cty.Object(map[string]cty.Type{ + "boop": cty.Number, + }), + }), + cty.Object(map[string]cty.Type{ + "foo": cty.Bool, + "bar": cty.String, + "baz": cty.Object(map[string]cty.Type{ + "boop": cty.Number, + "beep": cty.Bool, + }), + }), + `attribute "baz": attribute "beep" is required`, + }, } for _, test := range tests {