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

Fixes wrong result in ListAccessUsers due to loop variable messing with pointers #1482

Merged

Conversation

auyer
Copy link
Contributor

@auyer auyer commented Jan 17, 2024

Description

Changes the variable used for pagination to be inside the loop, and avoid the wrong values in pointers.

4172f09 fixes #1481

Has your change been tested?

Yes, following the steps described in the issue.

account := cloudflare.AccountIdentifier("account_id")
res, info, err := api.ListAccessUsers(ctx, account, cloudflare.AccessUserParams{})
u, _ := json.Marshal(res)
fmt.Println(string(res))

I tried to create a test that proves the issue with the pointers (a test that would fail without my changes), but the compiler is force-optimizing all pointers to bool I create into the same one.

I have however a real case to show:
This is my user in ZeroTrust:
evidence

This is what the code above above returns (ignoring the other users)
This is what the sniplet above returns (ignoring the other users)

{
  "id":"411e...",
  "access_seat":false,
  "active_device_count":0
  "created_at":"2024-01-15T13:26:34.003612Z",
  "email":"rafael.passos@...",
  "gateway_seat":false,
  "last_successful_login":"2024-01-17T13:48:31Z",
  "name":"Rafael ... Passos",
  "seat_uid":"4042b...",
  "uid":"411e...",
  "updated_at":"2024-01-17T13:48:33.499622Z"
}

And with my changes:

{
  "id":"411e...",
  "access_seat":true,
  "active_device_count":0
  "created_at":"2024-01-15T13:26:34.003612Z",
  "email":"rafael.passos@...",
  "gateway_seat":true,
  "last_successful_login":"2024-01-17T13:48:31Z",
  "name":"Rafael ... Passos",
  "seat_uid":"4042b...",
  "uid":"411e...",
  "updated_at":"2024-01-17T13:48:33.499622Z"
}

Types of changes

What sort of change does your code introduce/modify?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • This change is using publicly documented in cloudflare/api-schemas
    and relies on stable APIs.

Copy link
Contributor

changelog detected ✅

@auyer auyer marked this pull request as ready for review January 17, 2024 19:14
@jacobbednarz jacobbednarz merged commit 0d99944 into cloudflare:master Jan 30, 2024
10 checks passed
@github-actions github-actions bot added this to the v0.87.0 milestone Jan 30, 2024
github-actions bot pushed a commit that referenced this pull request Jan 30, 2024
Copy link
Contributor

This functionality has been released in v0.87.0.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2024
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.

ListAccessUsers returns wrong results for AccessSeat and GatewaySeat when it paginates due to loop variable
2 participants