Skip to content
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

Pass by value in for loop, not by reference. #953

Merged
merged 6 commits into from
Dec 21, 2023

Conversation

m3talsmith
Copy link
Contributor

When getting --json output of a list of organization members, the entire list of members were duplicates of the last member found. The issue is this list where all entries were the duplicated member, rather than a list where all entries were unique members.

The problem was that there was a for loop that was passing a pointer to a loop variable, to a function, where it was being used later; passing by reference. This meant that the only value used was the last value in the loop, as the value of the pointer changed with each iteration.

🔧 Changes

This PR passes the value of the member to the function, forcing a copy of the current iteration value, and preserving it from changes by the next iteration: pass by value.

📚 References

🔬 Testing

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@m3talsmith m3talsmith requested a review from a team as a code owner December 21, 2023 17:27
@m3talsmith m3talsmith force-pushed the issue-948-duplicate-last-user-in-json branch from b866f21 to b0e57ac Compare December 21, 2023 17:33
@codecov-commenter
Copy link

codecov-commenter commented Dec 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (859f796) 72.33% compared to head (b48438c) 72.33%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #953   +/-   ##
=======================================
  Coverage   72.33%   72.33%           
=======================================
  Files          92       92           
  Lines       12660    12660           
=======================================
  Hits         9158     9158           
  Misses       2959     2959           
  Partials      543      543           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

willvedd and others added 4 commits December 21, 2023 13:05
Bumps [github.com/hashicorp/terraform-exec](https://github.com/hashicorp/terraform-exec) from 0.19.0 to 0.20.0.
- [Release notes](https://github.com/hashicorp/terraform-exec/releases)
- [Changelog](https://github.com/hashicorp/terraform-exec/blob/main/CHANGELOG.md)
- [Commits](hashicorp/terraform-exec@v0.19.0...v0.20.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-exec
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…th0/auth0-cli into issue-948-duplicate-last-user-in-json
Copy link
Contributor

@willvedd willvedd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work

@m3talsmith m3talsmith merged commit 76f97dd into main Dec 21, 2023
8 checks passed
@m3talsmith m3talsmith deleted the issue-948-duplicate-last-user-in-json branch December 21, 2023 21:11
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.

auth0 organizations members list org_xxx error when outputting json
3 participants