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

Don't reuse response struct for multiple requests #191

Merged
merged 1 commit into from
Apr 11, 2022

Conversation

adamconnelly
Copy link
Contributor

A fix was added in #186 for the infinite loop while paging. The problem is that it didn't fix the underlying issue, and the fix actually breaks paging in certain circumstances. For example, if I have 13 repos, and a page size of 10, we'll do 13/10 = 1, which equals the page number of 1, and break without retrieving the second page).

The actual problem was that the responsePaginated variable was being reused in the loop, and the json decoder doesn't overwrite fields that aren't present in the response, so it was the Next field would end up with the value from the previous page, causing the same page to be requested forever.

A fix was added in ktrysmt#186 for the infinite loop while paging. The problem is that it didn't fix the underlying issue, and the fix actually breaks paging in certain circumstances. For example, if I have 13 repos, and a page size of 10, we'll do 13/10 = 1, which equals the page number of 1, and break without retrieving the second page).

The actual problem was that the `responsePaginated` variable was being reused in the loop, and the json decoder doesn't overwrite fields that aren't present in the response, so it was the `Next` field would end up with the value from the previous page, causing the same page to be requested forever.
Copy link
Owner

@ktrysmt ktrysmt left a comment

Choose a reason for hiding this comment

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

LGTM.

@ktrysmt ktrysmt merged commit 4d1e2d3 into ktrysmt:master Apr 11, 2022
@adamconnelly adamconnelly deleted the fix-paging branch April 11, 2022 14:29
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.

None yet

2 participants