In CustomizedDiff the 2nd return value of d.GetChange on a nested block (TypeSet) doesn't contain inner nested block #497
Labels
bug
Something isn't working
shims/maybe
Issues that may be caused by our backwards-compatibility shims.
subsystem/types
Issues and feature requests related to the type system of Terraform and our shims around it.
SDK version
Relevant provider source code
Schema definition:
Then define a
CustomizeDiff
, which in turns calld.GetChange("foo")
.Expected Behavior
The returned "new" value of
foo
should contain the new state defined in terraform configuration.Actual Behavior
The returned "new" value has
foo.b
with one element:nil
.Addtional Findings
I have debugged a bit on v1.6.0, and find the cause is that in
readListField()
it will modify theaddrPadded
to change the hash index of Set into a list index, which in turns will change affect the out address (as slice is passed by pointer in Go). In later step whend.GetChange
wants to get the value from diff for an address, it can't find the value, hence setting it tonil
.The fix is simply copy the
addrPadded
to a temporary list before calling:in file field_reader.go in
readListField()
.I suspect the same fix should be applied to the v1-maint branch.
The text was updated successfully, but these errors were encountered: