diff --git a/builtin/providers/test/resource.go b/builtin/providers/test/resource.go index 79c5b4a45..c8556a2b7 100644 --- a/builtin/providers/test/resource.go +++ b/builtin/providers/test/resource.go @@ -163,6 +163,15 @@ func testResourceRead(d *schema.ResourceData, meta interface{}) error { d.Set("computed_map", map[string]string{"key1": "value1"}) d.Set("computed_list", []string{"listval1", "listval2"}) d.Set("computed_set", []string{"setval1", "setval2"}) + + // if there is no "set" value, erroneously set it to an empty set. This + // might change a null value to an empty set, but we should be able to + // ignore that. + s := d.Get("set") + if s == nil || s.(*schema.Set).Len() == 0 { + d.Set("set", []interface{}{}) + } + return nil } diff --git a/helper/plugin/grpc_provider.go b/helper/plugin/grpc_provider.go index fc2bfea2f..6cdaaa1d9 100644 --- a/helper/plugin/grpc_provider.go +++ b/helper/plugin/grpc_provider.go @@ -448,6 +448,7 @@ func (s *GRPCProviderServer) ReadResource(_ context.Context, req *proto.ReadReso return resp, nil } + newStateVal = normalizeNullValues(newStateVal, stateVal, false) newStateVal = copyTimeoutValues(newStateVal, stateVal) newStateMP, err := msgpack.Marshal(newStateVal, block.ImpliedType())