pulumi / pulumi-terraform-bridge

A library allowing Terraform providers to be bridged into Pulumi.
Apache License 2.0
194 stars 43 forks source link

Detailed diff displays diff for nested property when a block is removed #2399

Open VenelinMartinov opened 3 weeks ago

VenelinMartinov commented 3 weeks ago

What happened?

The detailed diff displays a diff on a nested property which was never specified when the containing block is removed:

  ~ prov:index/test:Test: (update)
      [id=newid]
      [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes]
    - maxItemsOneBlock: {
        - prop: <null>
      }
Resources:
  ~ 1 to update
  1 unchanged

Example

https://github.com/pulumi/pulumi-terraform-bridge/pull/2398 maxItemsOne block removed empty

Output of pulumi about

.

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

VenelinMartinov commented 5 days ago

The issue here is not with detailed diff but with the value saved in state. We return the correct thing in detailed diff:

detailedDiff=map[string]*pulumirpc.PropertyDiff{
     "listBlocks": &pulumirpc.PropertyDiff{
         state:         impl.MessageState{},
         sizeCache:     0,
         unknownFields: nil,
         Kind:          2,
         InputDiff:     false,
     },
 }

But in the state we have:

props=resource.PropertyMap{
 "id": {
     V:  "newid",
 },
 "listBlocks": {
     V:  []resource.PropertyValue{
         {
             V:  resource.PropertyMap{
                 "prop": {},
             },
         },
     },
 },
 "listProps":        {},
 "mapProp":          {},
 "maxItemsOneBlock": {},
 "setBlocks":        {},
 "setProps":         {},
 "stringProp":       {},
}

which gets display in an unexpected way by the detailed diff.

We should either remove the nil prop from the state or fix the detailed diff display logic here in the engine.