Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the behavior of the
NilRelaxed
plan modifier.The Terraform Plugin SDK silently updates the state for optional attributes, while the Plugin Framework does not. To bridge this gap, we introduced the
NilRelaxed
plan modifier in #248. However, as discussed in hashicorp/terraform-plugin-framework#510, we discovered that it cannot completely replicate the SDK's behavior.The SDK handles attributes with null or zero values in the following way:
When examining the relationship between configuration values and state values, the SDK considers these scenarios valid:
Of these scenarios, cases 2 and 3 generate non-empty plans in the Framework due to mismatches between configuration and state. The
NilRelaxed
plan modifier aimed to prevent unnecessary plan generation in these cases by adopting the previous state's value.However, due to constraints in Terraform's type system (go-cty), we discovered that case 2 cannot be handled - specifically, we cannot revert a plan that converts a zero value back to null without raising an error. Since case 2 only occurs during the first apply, we've decided to accept these plan generations as expected behavior.
Output from acceptance testing: