-
Notifications
You must be signed in to change notification settings - Fork 96
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
Semantic Equal on Sets expects identical order of elements #1061
Comments
Hey there @briankassouf 👋🏻 , thanks for reporting the bug and sorry you're running into trouble here. That definitely doesn't look correct and I think we should be able to resolve this with a tweak to that logic. There are a good number of places where sets can cause issues, although this one seems easily avoidable. I quickly drafted a fix in #1064 that you can try out if you'd like: go get -u github.com/hashicorp/terraform-plugin-framework@37749fd91ce93bc9490f52ab6a1c6ab96b2cc52e |
Thanks @austinvalle, I tried that patch out and it appears to fix the issue! |
@austinvalle Curious if there are any updates on the timeline for merging your patch? |
Hey there @briankassouf 👋🏻 , apologies but I haven't had a chance to return to this bug yet, but I'm hoping to spend some time on it in the next few weeks. Unforuntately, it's going to have a negative impact on all set performance in general, although there isn't really a way to avoid doing comparisons like this, since I believe that patch is the correct way to do it 🤷🏻. (also sets in general will always perform poorly with a large amount of elements in Terraform, because the same problem we have here is also repeated on the Terraform CLI side of things as well. If you can avoid using sets it's almost always preferable 😆 ) I'll ping back here with any updates! |
Module version
Relevant provider source code
Schema with SetNestedAttribute with a custom type
CaseInsensitiveStringType
that implementsStringSemanticEquals
.Terraform Configuration Files
Expected Behavior
Sets should not care about the order of the elements contained within. This is how the
SetValue.Equals
function behaves here:terraform-plugin-framework/types/basetypes/set_value.go
Lines 282 to 286 in 4260861
This property should hold for both Equals and Semantic Equals
Actual Behavior
Semantic Equals compares elements based on their index in the elements array and will result in plan changes if the order of elements and case of
value
change duringRead
on the Resource:terraform-plugin-framework/internal/fwschemadata/value_semantic_equality_set.go
Lines 131 to 166 in 4260861
This results in a plan output like:
The text was updated successfully, but these errors were encountered: