-
Notifications
You must be signed in to change notification settings - Fork 232
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
schema: fix unknown value validation bug #1047
Conversation
The validate function should exit early in the case that a value is not wholly known. This is the intent of the comment and earlier code in this file - however, subsequent refactors introduced a bug in which one aspect of validation was run for unknown values: deprecation warnings. Deprecation warnings for known values are generated by validateType lower down. This fix ensures that deprecation warnings are not shown for unknown values, while still ensuring we exit validation early for all unknown values.
Test fail is due to the content type issue fixed in #1045. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, @kmoe 🚀 Thanks so much for fixing this! Double checked that indeed there is deprecation warning handling later on and covering unit testing of null vs known values for it.
For what it's worth, folks will no longer have a feedback mechanism about setting these to unknown -> null before the attribute is fully removed, resulting in a configuration breaking change for them. I assume you folks think that tradeoff is worth it, which is why I opted to pull this in. The same change also needs to be done in terraform-plugin-framework, which is only checking an attribute value is not null directly: |
…own values Reference: hashicorp/terraform-plugin-sdk#1047 Reference: hashicorp/terraform#31730 This change is made to keep terraform-plugin-sdk and terraform-plugin-framework behaviors for deprecation warning handling in sync.
Framework change: hashicorp/terraform-plugin-framework#465 |
Note that this was put in specifically to help warn about users assigning values to deprecated attribute during validation. Without this validation will pass with no warnings at all. The logic of the check was that an unknown value indicates that the attribute has been assigned at some point in the configuration, therefore the user should be warned. Even if the value ends up being null, the warning serves to communicate to the user that the attribute is being removed and will result in an error in a future version. Without this warning, users can more easily end up on a situation where upgrades cause the configuration to become invalid, and rolling back may not be easy. |
…own values (#465) Reference: hashicorp/terraform-plugin-sdk#1047 Reference: hashicorp/terraform#31730 This change is made to keep terraform-plugin-sdk and terraform-plugin-framework behaviors for deprecation warning handling in sync.
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. |
See hashicorp/terraform#31730
The
validate
function should exit early in the case that a value is not wholly known. This is the intent of the comment and earlier code in this file - however, subsequent refactors introduced a bug in which one aspect of validation was run for unknown values: deprecation warnings.Deprecation warnings for known values are generated by
validateType
lower down.This fix ensures that deprecation warnings are not shown for unknown values, while still ensuring we exit validation early for all unknown values.