-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Dirty plan when schema contains a nested computed attribute that also has a computed attribute. #32522
Comments
Hi @dimuon, Thanks for filing the issue. The proposed plan here is not generated by Terraform, but by the provider, so there's nothing we can do in this repo to fix the problem. I think rather than going through the provider issue tracker first, you can probably file this directly with the Terraform Plugin Framework, since that is likely the source of the recomputed attributes during the plan. Thanks |
Hi @dimuon, I'm actually going to re-open as a core issue for now. The fact that the framework allows a nested attribute to be |
Hi @jbardin, Thank you for the prompt response. It looks like the issue is caused by the fact that TF client doesn't include the current state values in Please compare 2 attached screenshots. The non-computed attribute behavior (the correct one): The computed attribute behavior: The only diff between these two cases is the following change in the schema:
The error happens when Also please mind the fact that non-computed attributes, e.g. |
@dimuon if you'd like to extract the MessagePack data from the protocol, you can use the
You can then use tooling such as https://github.com/wader/fq to inspect the data: $ fq -d msgpack tovalue 1673965915883_PlanResourceChange_Request_ProposedNewState.msgpack
{
"gap0": "-23 09:27:50 EST",
"length": 3,
"pairs": [
{
"key": {
"length": 2,
"type": "fixstr",
"value": "id"
},
"value": {
"length": 1,
"type": "fixstr",
"value": "5"
}
},
{
"key": {
"length": 5,
"type": "fixstr",
"value": "items"
},
"value": {
"elements": [
{
"length": 2,
"pairs": [
{
"key": {
"length": 6,
"type": "fixstr",
"value": "coffee"
},
"value": {
"length": 6,
"pairs": [
{
"key": {
"length": 11,
"type": "fixstr",
"value": "description"
},
"value": {
"type": "nil",
"value": null
}
},
{
"key": {
"length": 2,
"type": "fixstr",
"value": "id"
},
"value": {
"type": "positive_fixint",
"value": 1
}
},
{
"key": {
"length": 5,
"type": "fixstr",
"value": "image"
},
"value": {
"type": "nil",
"value": null
}
},
{
"key": {
"length": 4,
"type": "fixstr",
"value": "name"
},
"value": {
"type": "nil",
"value": null
}
},
{
"key": {
"length": 5,
"type": "fixstr",
"value": "price"
},
"value": {
"type": "nil",
"value": null
}
},
{
"key": {
"length": 6,
"type": "fixstr",
"value": "teaser"
},
"value": {
"type": "nil",
"value": null
}
}
],
"type": "fixmap"
}
},
{
"key": {
"length": 8,
"type": "fixstr",
"value": "quantity"
},
"value": {
"type": "positive_fixint",
"value": 2
}
}
],
"type": "fixmap"
}
],
"length": 1,
"type": "fixarray"
}
},
{
"key": {
"length": 12,
"type": "fixstr",
"value": "last_updated"
},
"value": {
"length": 15,
"type": "fixstr",
"value": "Tuesday, 17-Jan"
}
}
],
"type": "fixmap"
} Using this we are able to see from the protocol data that core is copying the configuration Given the current core logic, this is expected, but as @jbardin notes there may be some potential to change that in this specific scenario: an |
@bflad , @jbardin , thank you for the prompt responses - much appreciated. Also thank you for the tip regarding Does the answer mean that, e.g. we cannot use
|
OK, so from what I see on my local, the mentioned schema for It means, e.g., that the provider cannot return set with another cardinality after apply. |
Actually, it looks like in case of |
Just a note - it looks like the proposed fix also works for nested maps if a map is computed and optional and contains computed and optional underlying attributes. |
@jbardin , thanks for the fix. How do you think when we can expect it to be released? I guess it won't be in v1.4.0, correct? |
@dimuon if that PR referenced above fixes the issue, then it should appear in v1.4.x and alpha releases for 1.4. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Version
Terraform Configuration Files
Debug Output
The issue can be reproduced on the TF
hashicups
example with slight modifications of the schema. Please refer tohttps://github.com/dimuon/terraform-provider-hashicups-pf/tree/nested-attributes-issue
Expected Behavior
The plan output should be empty after apply.
Actual Behavior
The plan is always dirty, even if the TF configuration hasn't changed.
The schema of
hashicups_order
resource definescoffee
as a nestedComputed
andOptional
attribute that hasComputed
attributes (e.g.name
):Steps to Reproduce
Run
make error
in https://github.com/dimuon/terraform-provider-hashicups-pf/tree/nested-attributes-issue.The script starts docker image with
hashicups
server and runs tests against it.The
TestAccOrderResource
fails withorder_resource_test.go:10: Step 1/3 error: After applying this test step, the plan was not empty.
Additional Context
No response
References
https://github.com/dimuon/terraform-provider-hashicups-pf/tree/nested-attributes-issue
The text was updated successfully, but these errors were encountered: