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

the destroy plan should use correct type #32988

Merged
merged 1 commit into from
Apr 6, 2023

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Apr 5, 2023

When we plan to destroy an instance, the change recorded should use the correct type for the resource rather than DynamicPseudoType. Most of the time this is hidden when the change is encoded in the plan, because any null is always encoded to the same value, and when decoded it will be converted to the schema type. However when apply requires creating a second plan for an instance's replacement that value is not going to be encoded, and remains a dynamic value which is sent to the provider.

Most providers won't see that either, as the grpc request also encodes and decodes the value to conform with the correct schema. The builtin terraform provider does get the raw cty value though, and when that dynamic value is returned validation fails when the type does not match.

Fixes #32985

When we plan to destroy an instance, the change recorded should use the
correct type for the resource rather than `DynamicPseudoType`. Most of
the time this is hidden when the change is encoded in the plan, because
any `null` is always encoded to the same value, and when decoded it will
be converted to the schema type. However when apply requires creating a
second plan for an instance's replacement that value is not going to be
encoded, and remains a dynamic value which is sent to the provider.

Most providers won't see that either, as the grpc request also encodes
and decodes the value to conform with the correct schema. The builtin
terraform provider does get the raw cty value though, and when that
dynamic value is returned validation fails when the type does not match.
@jbardin jbardin added the 1.4-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Apr 5, 2023
@jbardin jbardin requested a review from a team April 5, 2023 14:40
@jbardin jbardin merged commit acbcbcb into main Apr 6, 2023
@jbardin jbardin deleted the jbardin/destroy-plan-null-type branch April 6, 2023 13:53
@github-actions
Copy link

github-actions bot commented Apr 6, 2023

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.4-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"object required, but received dynamic" error when applying terraform_data resource
3 participants