internal/fwschemadata: Rewrite SetValue
semantic equality logic to ignore order
#1064
+425
−21
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.
Closes #1061
This PR fixes the set semantic equality logic, which prior to this change, was written equivalent to list semantic equality.
Sets are unordered, so to correctly compare the semantic equality of two sets, we must compare each element in the set against all other elements to determine if there is a semantically equivalent element in the set. Once we find a semantically equal element, we remove it from the slice of candidates and continue.
As an example, consider a set of case insensitive strings.
With the previous logic, the following sets would be considered semantically equal:
However the following set would be incorrectly considered semantically not equal, due to the difference in order:
This change will result in both of these examples being considered semantically equal.
Corner tests
I also wrote some acceptance tests to make it a little easier to understand the impact (using IPv6 address strings as an example)
hashicorp/terraform-provider-corner#297
Unit test failures before the fix
https://github.com/hashicorp/terraform-plugin-framework/actions/runs/12832297072/job/35784696031?pr=1064