Skip to content

fix(gitea): walk every page of PR files and commits - #3022

Merged
IsmaelMartinez merged 1 commit into
The-PR-Agent:mainfrom
ylcn91:fix/gitea-pr-pagination
Sep 4, 2026
Merged

IsmaelMartinez merged 1 commit into
The-PR-Agent:mainfrom
ylcn91:fix/gitea-pr-pagination

Conversation

@ylcn91

@ylcn91 ylcn91 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Gitea answers list endpoints one page at a time, 30 items by default, and
RepoApi.get_change_file_pull_request / get_pr_commits issued a single call
with no paging. Any PR past the page size was reviewed against a partial file
list, silently.

Both now walk the pages through one helper, _list_all_pages. The earlier
attempt in #2147 stalled on three points, and each is addressed here:

  • every page request keeps the header token auth the rest of the provider
    uses, so no credential lands in a query string
  • the walk stops only at an empty page, not at a page shorter than the
    requested limit: the server caps limit at its own MAX_RESPONSE_ITEMS,
    so a capped page must not end the walk early
  • a failure mid-way propagates to the existing handlers and yields the same
    empty result a failed call always did, never a partial list

The tests cover a multi-page walk for files and for commits, a server that
caps the page below the requested limit, header auth on every page, and the
mid-way failure. All five fail on main.

Closes #2138

Gitea serves list endpoints one page at a time, 30 items by default, and
RepoApi.get_change_file_pull_request / get_pr_commits issued a single
unpaged call, so a PR past the page size was reviewed against a partial
file list. Both now walk the pages until an empty one, keep header token
auth on every request, and let a failure mid-way fall through to the
existing handlers rather than returning a truncated list.

Closes The-PR-Agent#2138
@github-actions github-actions Bot added the bug label Sep 3, 2026
@qodo-code-review

qodo-code-review Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

Grey Divider

Sorry, something went wrong

We weren't able to complete the code review on our side. Please try again manually by commenting /agentic_review on this PR.

Grey Divider

Qodo Logo

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving. The one thing worth checking was whether the walk can actually end, and it can: Gitea's files and commits handlers clamp the page window to zero once you pass the end and answer with [] rather than the last page, so stopping on an empty page cannot spin. Same clamp in 1.23.6, the version in the report.

Qodo's run errored, so no review had landed here at all. Thanks for taking this on after it sat since December.

@IsmaelMartinez
IsmaelMartinez merged commit 5bd13bd into The-PR-Agent:main Sep 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Pagination Handling in Gitea Provider API Wrappers

2 participants