Serialize AttrSensitivePaths in a consistent order#36465
Merged
Conversation
The local format function for diagnostics didn't match the global formatting for the tfdiags package.
Create a single place to generate some common formats, mostly the format of a cty.Path. These were used in the tfdiags package, but need to be split out to prevent import cycles if we want to use them in any core package.
We can make the comparison a little more efficient by removing the reflection to create the Sprintf string.
liamcervante
approved these changes
Feb 11, 2025
Contributor
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Sensitive paths in a resource instance value were not serialized in a consistent order, which could cause comparison of the state to erroneously indicate a change. While the UI would not report any changes to the user because the states were functionally the same, the machine readable outputs, like the plan `applyable' field and the detailed exitcode would indicate that the plan was not empty.
The canonical user-readable version of a cty.Path is was created by the tfdiags package, but in order to reuse this everywhere we need, the formatting function needs to be split out to it's own package. This PR creates the
lang/formatpackage, delegates thetfgdiagsformat functions to the new package, then replaces any otherfmt.Sprintfformatting ofcty.PathI could find with the new more efficient formatter.Once we have a single format for
cty.Path, use that to sort theAttrSensitivePathsused in state so that the order is deterministic.Fixes #36403