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
Single Nesting Mode Blocks Not Null in PlanResourceChange ProposedNewState #32460
Comments
Adjusting the single nesting mode block proposed new state into null should be safe for terraform-plugin-sdk's |
By coincidence I found what I think is a different form of exactly the same bug yesterday while working on something entirely unrelated. 🙃 I was trying out the provider mocking part of the prototype over in #32321. The provider mocking prototype there works by wrapping an existing provider to retain its When wrapping SDKv2 providers that have resource types that use the SDK's special In my case I was testing the initial creation of the object rather than removing a block that had existed earlier, so I think this is the same bug but with Terraform core inserting an unknown value as a placeholder rather than retaining the previous value as we saw in the report above. I don't yet have a minimal reproduction independent of the module testing prototype but I think the minimal parts to reproduce it are:
I was able to work around it for what I was doing by adding an empty |
Thanks @apparentlymart! The original error was from I'm not sure yet how to replicate the |
For my mocking prototype in particular it's notable that it's running the provider's own But since I see you now have a PR up I'll try incorporating that PR into my branch and see if that has also somehow fixed that problem, or if that's something different going on. (Could well also be a bug in my own prototype code, since it's doing some pretty gross things to get the job done even though we don't really have any facilities in Terraform Core for ergonomic provider development. 🙄 ) |
I can't explain exactly why, but #32463 did actually fix the weird quirk in the provider mocking prototype. My hunch is that the non-null |
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
First apply:
Second apply:
Debug Output
Please reach out if you need this.
Expected Behavior
When applying the second configuration without the single nesting mode block, the proposed new state for the block is null to match the null configuration -- causing the plan succeed without provider-side modification.
Actual Behavior
Terraform returns an error due to the proposed new state not being null:
Using the
TF_LOG_SDK_PROTO_DATA_DIR
environment variable, such asTF_LOG_SDK_PROTO_DATA_DIR=/tmp
, will save files containing MessagePack data from the protocol before it reaches terraform-plugin-framework or provider logic. Viewing those files via https://github.com/wader/fq shows the disparity between the configuration and proposed new state data sent duringPlanResourceChange
.Please note if you want to create these files yourself, you likely need hashicorp/terraform-plugin-go#245, to prevent the files from being overwritten across acceptance test steps since the file naming is not time granular enough.
If the provider logic manually modifies the planned new state to match the configuration when its null, then the Terraform error goes away.
Steps to Reproduce
gh repo clone mvantellingen/terraform-pf-testcase
cd terraform-pf-testcase
TF_ACC=1 go test -count=1 -v ./...
Additional Context
Schema definition in terraform-plugin-framework:
References
The text was updated successfully, but these errors were encountered: