-
Notifications
You must be signed in to change notification settings - Fork 237
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
Fix nil pointer dereference in ResourceData.HasChangeExcept #811
Conversation
Hi @w-leads 👋 Thank you for submitting this. Is this change required to fix an issue or is it purely for code correctness? The change looks good and makes sense, just trying to confirm this detail first to see if there are potentially other related issues as well. Thank you! |
@bflad Thank you for the reply! This is just for fixing the error I encountered while developing a custom terraform provider. I quickly tried to search for a related issue or PR but could not find it. |
Great to know, @w-leads, and sorry you ran into trouble. Would you happen to have time to file a bug report so we can capture some of the details of how this happened? We would love to create some test cases to prevent future regressions. If not, no worries. Appreciate the time and effort you have put into this already. |
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.
Thank you again.
@bflad While checking the behavior to file a bug report, I noticed that probably I'm using the function in a wrong way.. |
Co-authored-by: Brian Flad <bflad417@gmail.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
Thank you for the followup, @w-leads 👍
You are correct, the More information about plan customization can be found at https://www.terraform.io/docs/extend/resources/customizing-differences.html, with some additional helpers available in the https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff package. |
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 🚀
Thank you very much for the information! Will look into the documents |
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. |
ResourceData.HasChangeExcept
andResourceData. HasChangesExcept
accesses.diff.Attributes
which could be nil and cause nil pointer dereference error.This PR fixes the issue by checking the value and if it's nil, then return false(meaning no changes)