Open wuxu92 opened 1 year ago
@wuxu92 always setting a value for a field into the state is intentional/by design - whilst terraform-plugin-sdk@v2
(and protocol v5) masks when items aren't set into the state - when we move to terraform-plugin-framework
(and protocol v6) all fields will need to be set into the state or an error is surfaced automatically - so requiring this now avoids bugs later (which is why we also require this is provider PR's).
That said, taking a look through above, it appears that the identity
block shouldn't be present within the encryption
block (and shout be surfaced one level higher) - so I think that case is ultimately a schema issue?
@tombuildsstuff is that always setting a value for a field into the state
means for the top-level fields? for these not-top-level fields we should not set them if not responded by API if i understand correctly.
the schema is a little bit different from common, there are two identity
blocks in this model, one is in top-level, and other one is under encryption
block and this one cause the issue.
in
func (m modelToModelAssignmentLine) assignmentForReadMapping
will init the sdk filed if it is nil in below code:https://github.com/hashicorp/pandora/blob/345c443985de0cfdf8fc102023201a502d39964c/tools/generator-terraform/generator/mappings/assignment_model_to_model.go#L75-L83
, and this will always set an item to the model which will encoded to tf state file.
https://github.com/hashicorp/pandora/blob/c316d20771273b211c180c55e6dfb806ac239f26/tools/generator-terraform/generator/mappings/assignment_direct.go#L658-L665
i tried with LoadTestService 2022-12-01 the AccTest raise such error below because the Read method will always set the
encryption
field even the api return theencryption
field as nil.