Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computed properties do not handle ordering changes properly #361

Open
2 tasks
arjunrajnetapp opened this issue Mar 29, 2023 · 0 comments · May be fixed by #362
Open
2 tasks

Computed properties do not handle ordering changes properly #361

arjunrajnetapp opened this issue Mar 29, 2023 · 0 comments · May be fixed by #362

Comments

@arjunrajnetapp
Copy link

Describe the bug

Readonly and optional computed properties have strange behaviour defined when under a list. If the ordering of the elements change, these properties do not "move" with the elements as expected.

To Reproduce

  1. Define a resource with an object list with a nested property that is readonly or computed. Sample YAML
  2. Create the resource with multiple elements in that object list, with only some elements where the computed property is populated. Sample HCL
  3. Switch the ordering of the list. The plan shows that the read only and computed fields "stay" in place. Sample HCL
  4. Apply the plan. The PUT request will show that computed fields are populated incorrectly in the payload. Any computed properties that were omitted in the plan can "absorb" the value from a neighbouring element.

Expected behaviour

The PUT request should be created as expected

Additional context

This seems more of a bug with terraform itself rather than the plugin, but a bandaid solution would help.

For pre-made tests to show the issue (though it has been fixed on the branch), check out TestAcc_ArrayBasedComputedPropertiesUpdateCorrectly and TestAcc_OrderIgnoredPlanIsStableWithReadOnlyProperties from the branch and file https://github.com/instaclustr/terraform-provider-openapi/blob/bugfix/fix-wrong-computed-properties-behaviour-on-updates/tests/e2e/gray_box_cdns_test.go

Checklist (for admin only)

Don't forget to go through the checklist to make sure the issue is created properly:

  • I have added a corresponding label (bug) to the issue (right side menu)
  • I have added this issue to the 'API Terraform Provider' GitHub project (right side menu)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant