8000 Serialize `AttrSensitivePaths` in a consistent order by jbardin · Pull Request #36465 · hashicorp/terraform · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Serialize AttrSensitivePaths in a consistent order #36465

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

Merged
merged 9 commits into from
Feb 11, 2025

Conversation

jbardin
Copy link
Member
@jbardin jbardin commented Feb 10, 2025

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/format package, delegates the tfgdiags format functions to the new package, then replaces any other fmt.Sprintf formatting of cty.Path I could find with the new more efficient formatter.

Once we have a single format for cty.Path, use that to sort the AttrSensitivePaths used in state so that the order is deterministic.

Fixes #36403

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.
@jbardin jbardin merged commit 17f4dcf into main Feb 11, 2025
8 checks passed
@jbardin jbardin deleted the jbardin/sensitive-order branch February 11, 2025 15:22
Copy link
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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drift detection " terraform plan --refresh-only --detailed-exitcode " exits with 2, even when there are no changes.
2 participants
0