Fix next page calculation bug in GitEa provider pagination#2161
Closed
Fix next page calculation bug in GitEa provider pagination#2161
Conversation
Deploying pipelines-as-code with
|
| Latest commit: |
bc4c183
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0927293b.pipelines-as-code.pages.dev |
| Branch Preview URL: | https://copilot-fix-776c106f-100f-40.pipelines-as-code.pages.dev |
Copilot
AI
changed the title
[WIP] there is a bug in calculation for next meeting
Fix next page calculation bug in GitEa provider pagination
Jul 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
ShouldGetNextPagefunction in the GitEa provider had incorrect logic for determining when to fetch the next page in pagination. This caused the provider to stop pagination prematurely after the first page when fetching pull request files or other paginated resources.Root Cause
The bug was in line 392 of
pkg/provider/gitea/gitea.go:Where:
irepresents the total number of pages from thex-pagecountheadercurrentPageis the current page being processedThis condition was backwards - it would return
false(don't fetch next page) when the total pages was greater than or equal to the current page, which is exactly when we should continue pagination.Example of the Bug
For a 5-page result set:
5 >= 1is true → returnsfalse(should betrue)5 >= 2is true → returnsfalse(should betrue)5 >= 5is true → returnsfalse(correct)This meant only the first page of results would ever be retrieved.
Solution
Fixed the condition to correctly compare current page against total pages:
Now the logic correctly identifies when we've reached the last page:
1 >= 5is false → returnstrue(correct)2 >= 5is false → returnstrue(correct)5 >= 5is true → returnsfalse(correct)Changes Made
ShouldGetNextPagefunctionTesting
All tests pass, including the new comprehensive test suite for
ShouldGetNextPagethat validates the fix across multiple scenarios. The fix ensures that GitEa provider will now correctly retrieve all pages of paginated results instead of stopping after the first page.Impact
This bug was preventing complete file change information from being retrieved in GitEa pull requests when the changes spanned multiple pages. The fix ensures all changed files are properly discovered and processed.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
api.bitbucket.org/tmp/go-build378190642/b1330/webhook.test -test.testlogfile=/tmp/go-build378190642/b1330/testlog.txt -test.paniconexit0 -test.failfast=true -test.timeout=20m0s(dns block)https://api.github.com/app/installations/tmp/go-build378190642/b1074/adapter.test -test.testlogfile=/tmp/go-build378190642/b1074/testlog.txt -test.paniconexit0 -test.failfast=true -test.timeout=20m0s(http block)https://api.github.com/app/installations/1234567/access_tokens/tmp/go-build378190642/b1491/github.test -test.testlogfile=/tmp/go-build378190642/b1491/testlog.txt -test.paniconexit0 -test.failfast=true -test.timeout=20m0s(http block)/tmp/go-build2210641935/b1169/github.test -test.testlogfile=/tmp/go-build2210641935/b1169/testlog.txt -test.paniconexit0 -test.timeout=10m0s(http block)https://api.github.com/repos/owner/repo/hooks/tmp/go-build378190642/b1383/webhook.test -test.testlogfile=/tmp/go-build378190642/b1383/testlog.txt -test.paniconexit0 -test.failfast=true -test.timeout=20m0s(http block)mybelovedhubIf you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.