Skip to content

Conversation

@kristoflemmens
Copy link
Contributor

This PR should fix #184

The issue of the infinite loop is because responsePaginated.Next will never be empty. In the end it will always return the last URL.
Another issue was with authenticating the next request. I added this as well.

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 7dc3dd0 into ktrysmt:master Mar 11, 2022
@drewmoseley
Copy link

Thank you for this.

adamconnelly added a commit to spacelift-io/go-bitbucket that referenced this pull request Apr 7, 2022
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.
adamconnelly added a commit to spacelift-io/go-bitbucket that referenced this pull request Apr 7, 2022
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.
adamconnelly added a commit to spacelift-io/go-bitbucket that referenced this pull request Apr 7, 2022
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.
ktrysmt pushed a commit that referenced this pull request Apr 11, 2022
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.
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.

Error running list_test

3 participants