Skip to content

fix(permission): stabilize Read order to eliminate spurious no-op diffs - #320

Open
Mahanmmi wants to merge 2 commits into
jfrog:mainfrom
Mahanmmi:fix-no-op-state-drift
Open

fix(permission): stabilize Read order to eliminate spurious no-op diffs#320
Mahanmmi wants to merge 2 commits into
jfrog:mainfrom
Mahanmmi:fix-no-op-state-drift

Conversation

@Mahanmmi

Copy link
Copy Markdown

A permission with multiple targets (or actions.users / actions.groups) shows a no-op diff on every terraform plan — items swap positions even though nothing actually changed:

targets: [
  ~ [0]: { ~ name: "ANY REMOTE" => "my-repo-local" }
  ~ [1]: { ~ name: "my-repo-local" => "ANY REMOTE" }
]

The cause is in fromResourceAPIModel and fromUsersGroupsAPIModel: the API response is unmarshaled into a Go map, then turned into a slice with lo.MapToSlice before being wrapped in a types.Set. Go map iteration is randomized, so the intermediate slice comes out in a different order on every Read, and that order leaks into state.

Fix: sort the slice by name before calling types.SetValue. Added a small sortAttrValuesByName helper and call it in both spots.

@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@Mahanmmi

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@soumyas-dev

Copy link
Copy Markdown
Collaborator

Hi @Mahanmmi ,

Thank you for your contribution.

Our CI pipeline issues have been resolved, and we are now accepting contributions again. If you are still interested in submitting this change, please rebase your branch on master and update the CHANGELOG. We look forward to reviewing your pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants