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

Update pagination to compute current page based off total_count #1372

Merged
merged 4 commits into from
Aug 24, 2023

Conversation

jroyal
Copy link
Contributor

@jroyal jroyal commented Aug 24, 2023

Also fixes pagination for a few Access Resources

Description

In terraform, if you try to use the Access Application Resource in a datasource it will fail to find the app because the List function will only check the first page.

Has your change been tested?

Unit tests and a local reproduction of the original issue that is now resolved.

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.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 24, 2023

changelog detected ✅

@jroyal
Copy link
Contributor Author

jroyal commented Aug 24, 2023

@jacobbednarz tbh I'm a little hesitant on the new commit about changing total_count in all the tests. That was why the tests were failing.

I think its the correct fix, since count should always equal total_count if there are less than 1 page worth of results. Since most tests only have 1 item this should make the tests match real behavior. I couldn't decide if should try to handle that differently though in pagination.go?

@jacobbednarz
Copy link
Member

iirc, the test data came from the old API docs which didn't have real validation so it may have been incorrect the entire time. I think fixing the tests here is the right move if we've uncovered issues.

@jacobbednarz
Copy link
Member

it's worth noting, we also don't have thorough impossible logic checks for pagination which we could firm that up but I suspect there are some services that have a misunderstanding of all the result info fields so it may be better to fix to be more clear instead.

(the second part is already something we are speaking about internally too)

@codecov-commenter
Copy link

Codecov Report

Merging #1372 (5b8eed4) into master (b9ac804) will increase coverage by 0.00%.
Report is 191 commits behind head on master.
The diff coverage is 49.62%.

@@           Coverage Diff            @@
##           master    #1372    +/-   ##
========================================
  Coverage   48.33%   48.34%            
========================================
  Files         133      139     +6     
  Lines       13023    13749   +726     
========================================
+ Hits         6295     6647   +352     
- Misses       5201     5453   +252     
- Partials     1527     1649   +122     
Files Changed Coverage Δ
access_audit_log.go 79.31% <ø> (ø)
access_bookmark.go 72.44% <ø> (ø)
access_keys.go 71.42% <ø> (ø)
access_organization.go 53.84% <ø> (ø)
access_service_tokens.go 51.85% <ø> (ø)
account_members.go 65.54% <ø> (ø)
account_roles.go 53.84% <ø> (ø)
accounts.go 50.81% <ø> (ø)
addressing_address_map.go 39.04% <ø> (ø)
addressing_ip_prefix.go 45.45% <ø> (ø)
... and 121 more

... and 1 file with indirect coverage changes

@jacobbednarz jacobbednarz merged commit 75a2319 into cloudflare:master Aug 24, 2023
11 checks passed
@github-actions github-actions bot added this to the v0.76.0 milestone Aug 24, 2023
@jacobbednarz
Copy link
Member

thanks for this!

github-actions bot pushed a commit that referenced this pull request Aug 24, 2023
@github-actions
Copy link
Contributor

This functionality has been released in v0.76.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 Aug 29, 2023
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.

3 participants