-
Notifications
You must be signed in to change notification settings - Fork 95
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
Private State is lost after a failed Deletion #863
Comments
Hi @AmadeusK525 👋 Thank you for reporting this and sorry you are running into trouble with this. We'll need to confirm whether this is something the framework is causing and can be fixed in this repository or if Terraform core is dropping this data in this situation. I believe the framework should be automatically setting the terraform-plugin-framework/internal/fwserver/server_deleteresource.go Lines 85 to 87 in cd4d1ec
If you're able, could you try running Terraform with the |
😅 Looking at that code there right after I posted it, it actually is setting the request data but not the response data. We might need to decide the right thing to do in this case, but my hunch is that we might need to populate the data except when there are no error diagnostics from the provider logic. To immediately fix your situation, you might want to temporarily have your provider logic copy the private state data from the request to the response. |
Hey @bflad, sorry for the lack of info on the issue, I posted it by accident prior to writing everything out lol I've been collecting the Trace output and was about to encrypt it and actually describe everything in the issue. Anyway, thanks for responding quickly, I'll get back to you in a sec |
Heyo @bflad, I tried running the deletion with the env var set but the dir was unchanged. |
Oh, |
It has no Maybe this bug is an unintended side-effect of the rule? |
It's possible that when we originally designed the feature, we expected Terraform to keep the private data in the case of an error diagnostic instead of needing the provider to return it, since that is what happens with "regular" state data. I reached out to the Terraform core folks and it does appear that the core logic is just always using the response private data field regardless of errors being returned. To fix this what we'll likely do is:
I'll tag this for a bug fix release sooner rather than later, given the data loss situation. |
Thanks a lot! 😄 |
Reference: #863 The previous implementation assumed that Terraform core would preserve private state similar to "regular" state when a provider returned an error diagnostic while destroying a resource. The core implementation instead always uses the response data, which the framework was previously always discarding. This change corrects the errant design while also enabling provider logic to potentially update the private state in this situation.
Reference: #863 The previous implementation assumed that Terraform core would preserve private state similar to "regular" state when a provider returned an error diagnostic while destroying a resource. The core implementation instead always uses the response data, which the framework was previously always discarding. This change corrects the errant design while also enabling provider logic to potentially update the private state in this situation.
Hi again 👋 terraform-plugin-framework v1.4.2 has been released which should resolve this issue. Please reach out in a new issue if you are still running into unexpected behaviors. Thank you! |
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. |
Module version
Relevant provider source code
Terraform Configuration Files
...
Debug Output
Expected Behavior
When saving private state resources, they should be accessible by the CRUD methods and should not be dropped/altered if the operation that modified them return with error diagnostics (just like normal states) for further use/re-use
Actual Behavior
If the Delete (I haven't tested other CRUD methods to see if the behavior is the same) call is made and fails (thus, the resource was NOT deleted), the Private state is completely wiped and can't be accessed in further calls to the CRUD methods
Steps to Reproduce
The text was updated successfully, but these errors were encountered: