Skip to content

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 requested a review from a team as a code owner February 10, 2025 21:26
@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
@github-actions
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