Stabilize Terraform plan fingerprints across UI hint ordering #108
No reviewers
Labels
No labels
app-migration
bug
ci-cd
cluster
Documentation
duplicate
enhancement
gpu
invalid
networking
question
security
Storage
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Homelab/workflows!108
Loading…
Reference in a new issue
No description provided.
Delete branch "kiyi/terraform-plan-fingerprint"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Terraform can reorder
relevant_attributesUI hints between otherwise identical plans, causing a false approval-fingerprint mismatch. Private Terraform apply run 71 stopped before apply with a different fingerprint from passing plan run 70, despite the same source, workflows v1.42.0 binding and eight-create public summary. The mismatch guard correctly prevented mutation.Reproduction: five credential-free Terraform 1.16.5 mocked Vault exports produced three different outer orders of the same three relevant attributes. All other exported fields were identical. Terraform defines these attributes as an unordered set of UI hints; its JSON exporter attempts to sort the output using indexes into the original unsorted slice. This reproduces a false mismatch without retrieving either live plan; live acceptance still remains required.
Normalize only that outer metadata list before hashing. Retain every member, field and duplicate, preserve attribute-path and all other list order, and continue binding variables, prior state, configuration, values/unknown markers, drift, checks and resource changes. Keep exact source/fingerprint approval, plan/action guards, name-absence checks, private saved-plan apply and confidentiality. No workflow/job/status names or caller inputs change.
Validation at
88ab4f4: the six-permutation regression fails against the old implementation and passes with the fix. All 37 identity/delivery/state/approval/confidentiality tests pass, including changed hint content, membership, duplicates, ordered input values, prior state and real plan changes. Native staged Gitleaks 8.30.1 and diff checks passed. All Terraform execution used existing mocked providers; no real local plan/apply, credentials or live APIs. Hosted checks remain required.After review/checks/merge, publish and promote one release to stable-v1, then start a fresh owning identity plan and review its new fingerprint before a separately approved apply. Fingerprints from runs 70/71 must not be reused across this fingerprint-contract change. No workflow retry is dispatched by this PR.
Source review at
88ab4f44b2: approved.plan_summarynormalizes only the top-levelrelevant_attributesouter list using a canonical JSON sort key; it retains each hint, duplicates, nested attribute-path order, and the rest of the plan in the hash. The approval guard still binds the source SHA and fresh plan fingerprint before applying the private saved plan; resource/action and identity creation guards remain unchanged. Inspected regression tests for all six hint permutations, changed hint contents/membership/duplicates, ordered input values, changed prior state/resource changes, and apply mismatch. HashiCorp's pinned Terraform 1.16.5 source describes these as UI-only hints and states their order is unimportant, supporting this narrowly scoped normalization. This PR does not alter UDS deployment packaging, policy/admission, or routing ownership. Hosted Workflow acceptance, Repository security, and Library checks were pending at review time; I did not independently run tests or a live plan/apply. Approval is source-only and does not satisfy required CI or authorize a merge. After release/promotion, obtain a new owning plan and fresh approval fingerprint; do not reuse pre-change fingerprints.CI at submission: pending. This is a source-review approval, not a scan verdict; required checks still block merge.
kiyi referenced this pull request from Homelab/Documentation2026-10-15 21:51:23 -05:00