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

Backport of Convert variable types before applying defaults into v1.3 #32139

Conversation

teamterraform
Copy link
Contributor

Backport

This PR is auto-generated from #32027 to be assessed for backporting due to the inclusion of the label 1.3-backport.

WARNING automatic cherry-pick of commits failed. Commits will require human attention.

The below text is copied from the body of the original PR.


Fixes #31978

Currently Terraform attempts to apply defaults in variables before calling go-cty to convert the variables into their actual concrete types. This can lead to a situation where HCL cannot apply the defaults because of a type incompatibility and then panics and crashes Terraform (#31978). It's kind of impossible to recover from or predict this situation without modifying the HCL public functions (eg. make the panic return an error, or add a new function like CheckCanApplyDefaults). We can't do this check with go-cty because as far as go-cty is concerned these are perfectly valid conversions. Note, that HCL and go-cty disagree here about what is or what isn't a valid type conversion.

This PR switches the order of these operations. We now go through go-cty to convert to the concrete type first, then when we call the apply defaults function the types are guaranteed to match and HCL doesn't need to worry about any kind of conversions.

This change requires an upstream fix in go-cty, so go-cty is updated as part of this change.

Target Release

1.3.4

Draft CHANGELOG entry

BUG FIXES

  • Input and Module Variables: Convert variable types before attempting to apply default values

@teamterraform teamterraform force-pushed the backport/liamcervante/convert-before-defaults/commonly-improved-bobcat branch from 6e93746 to c96437e Compare November 2, 2022 08:38
@liamcervante liamcervante merged commit 2e96550 into v1.3 Nov 2, 2022
@liamcervante liamcervante deleted the backport/liamcervante/convert-before-defaults/commonly-improved-bobcat branch November 2, 2022 08:52
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

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
Contributor

github-actions bot commented Dec 3, 2022

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 Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants