fix(merge-queue): paginate Gitea API list calls — issues, statuses (#2366/#588) #2367
Reference in New Issue
Block a user
Delete Branch "fix/gitea-merge-queue-pagination"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The merge queue used hard-coded
limit=50on list endpoints, silently truncating enumeration when more than 50 open PRs or status checks exist.Fix
api_paginated()helper that loops through pages until a partial page is returned.list_queued_issues()andlist_candidate_issues()now enumerate ALL open PRs.get_combined_status()/statusesenrichment now paginates beyond the 50-entry cap.Tests
All 52 gitea-merge-queue tests pass.
Refs: #2366/#588, PM dispatch 01eaa317.
REQUEST_CHANGES: head
9013d224f4is not safe to merge. Full diff against fresh origin/main is not scoped to the pagination fix:git diff origin/main..HEAD --name-statuschanges.gitea/scripts/gitea-merge-queue.pyand.gitea/scripts/sop-tier-check.sh, with no test-file diff. The sop-tier-check collateral reintroducesSOP_FAIL_OPEN=1exit-0 branches that core#2362 removed, including jq install failure, token whoami failure, PR head read failure, org teams read failure, and reviews fetch failure. That is a stale-base regression/fail-open. Separately, the new status pagination path is not fail-closed:get_combined_status()catchesApiError/network failures fromapi_paginated(.../statuses)and continues withall_statuses = [], so an unreadable/error page can silently degrade to an incomplete status set. For this merge-control keystone, unreadable pagination must abort/hold loudly rather than proceed on partial data. Please rebase onto current main, remove the sop-tier-check collateral, add/restore tests for the pagination paths, and make paginated status/list reads fail closed on page errors.REQUEST_CHANGES on head
9013d224f4.Full-diff-scope blocker: this PR is not pagination-only.
git diff origin/main..origin/pr/2367 --name-statusshows both.gitea/scripts/gitea-merge-queue.pyand.gitea/scripts/sop-tier-check.sh. Current main has noSOP_FAIL_OPENinsop-tier-check.sh, but this head reintroduces exit-0 fail-open branches at sop-tier-check.sh:72-75, 109-112, 122-125, 218-221, and 275-278. That regresses the just-landed SOP fail-closed hardening.Pagination-specific blocker:
get_combined_status()still catchesApiErrorfrom the paginated/statusesfetch and continues withall_statuses = []at gitea-merge-queue.py:703-710. The requested contract was unreadable/error page => fail-closed, not a partial status set.Required fix: rebase/rebuild onto current main so
sop-tier-check.shis not modified / SOP_FAIL_OPEN is not reintroduced, and make the paginated statuses path fail closed (or prove in tests why partial status fallback cannot hide a required/advisory context).9013d224f4to29d15cbe2cAPPROVED: verified amended head
29d15cbe2c. Full diff against fresh origin/main is scoped to.gitea/scripts/gitea-merge-queue.pyand.gitea/scripts/tests/test_gitea_merge_queue.py;sop-tier-check.shis no longer in the diff andSOP_FAIL_OPENis absent there.api_paginated()walks pages until a partial page and raises on non-list responses; list_queued_issues/list_candidate_issues now use it;get_combined_status()no longer swallows paginated/statuseserrors, so ApiError propagates instead of degrading toall_statuses=[]. New tests cover multi-page accumulation, non-list failure, and statuses-error propagation. Live PR is mergeable; required core contexts are green (CI / all-required,E2E API Smoke Test,Handlers Postgres Integration). Combined status remains red from non-required governance/path gates, not the required merge bar.APPROVED on head
29d15cbe2c.Independent re-review: full diff is limited to
.gitea/scripts/gitea-merge-queue.pyand.gitea/scripts/tests/test_gitea_merge_queue.py;sop-tier-check.shis no longer in the diff andSOP_FAIL_OPENis absent on the branch.api_paginated()loops pages until a partial page and raises on non-list responses;list_queued_issues()/list_candidate_issues()now enumerate all open PRs;get_combined_status()now propagates paginated/statuseserrors instead of using a partial status list. Regression tests cover multi-page pagination, non-list page rejection, and/statuseserror propagation.Live status check after rerun: CI/all-required, E2E API Smoke, Handlers Postgres, Ops Scripts Tests, and lint-required-no-paths are green; mergeable=true.