Repository navigation
Description
Problem
_fetch_all_pages (src/devops_cli/github/rate_limiter.py:1590-1624, at 79e1e93), which run_gh uses for every gh api --paginate call through _run_gh_paginated, fails open:
- A page that exits 0 with empty stdout ends the loop (
:1613-1615), the same as a literal[]. - When
extract_json_payloadreturns None, or a JSON object on a later page,_append_paginated_datareturns False and the loop breaks (:1617-1621). - Either way
_fetch_all_pagesreturnsis_exhausted=True(:1624), so_run_gh_paginatedreports exit 0 with the items read so far.
A bad first page therefore reads as an empty listing, and a bad later page as a short one, and no caller can tell. Such pages happen: a proxy's HTML error page, a truncated body, a {"message": ...} error object. extract_json_payload (:388) also scans non-JSON output for the first [ or {, so a body with a preamble can be partly accepted.
Reproduced during #740's review with the real run_gh and a stubbed run_subprocess: page 1 returning <html>upstream</html> gave [] with exit 0, and page 2 returning it gave only page 1's 100 items. #740 works around it by reading and validating each page itself (GitHubRoadmapStore._read_listing). These callers still rely on the shared reader:
commands/pr.py:1295and:1456(PR readiness),github/check_verdict.py:263(check runs),github/pr_monitor.py:326,:410,:516;github/issues.py:138and:393,github/projects.py:783,github/client.py:456,commands/gh.py:1289(devops gh api --paginate).
A short check-run or review-thread listing can make a readiness check pass on data it never saw.
Acceptance criteria
- A page that exits 0 but is empty, is not JSON, or is not the expected shape (a JSON list, or the check-runs object
run_ghalready accepts) is a failed read:run_ghreturns a non-zero result whose stderr names the endpoint and the page. A literal[]page still ends a listing normally. -
extract_json_payloadis not used to salvage a paginated page: a page with a preamble before its JSON is a failed read. - Tests through the real
run_ghwithrun_subprocessstubbed: an HTML page, an empty page, a truncated body and an error object, each on page 1 and on a later page, give a failed read naming the page; a normal listing that ends with[]or a short page still succeeds. Offline, each well under 1 s. - A PR-readiness test: a check-run listing whose second page is malformed makes
devops pr check-readinessreport the read failure instead of evaluating the first page's checks. -
changelog.d/1034.mdrecords the fix under### Fixed.CHANGELOG.mdis not edited. -
uv run devops cipasses.
Key questions
- Fix each caller instead? (proposed) No. The reader is the one place every
--paginatecall goes through; feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740's per-page validation is a workaround that can move onto the shared reader once this lands. - Does refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (the GitHub session owns transport, ledger, error classes and link pagination) cover it? (proposed) refactor(github): the github session owns transport, ledger, error classes and link pagination #983 rewrites pagination in v0.2.28. This fixes the fail-open now with a small change; refactor(github): the github session owns transport, ledger, error classes and link pagination #983 keeps the rule when it moves the code.
Depends on: none.
Order: before #983 (v0.2.28), which carries the rule forward. #740 can drop its own page validation after this lands.
Related: #740, #983, #767.
Update 2026-10-08: amended criteria (assessed against release/v0.2.29, 910b823)
Why the criteria above are not enough on their own. _query_timeline_copilot_state (src/devops_cli/github/pr_monitor.py:326-345) pages with --paginate and --jq together. run_gh applies --jq to every page, so a page comes back as filtered lines, empty output or a single object, never a JSON list. Under this item's rule every one of those is a failed read. Copilot state then becomes "unread", which goes into the merge-failure reasons (pr_monitor.py:553-554), so devops pr wait and devops pr monitor would never report a PR as ready.
- Checked offline. On 910b823, two matching timeline events already come back as
[], the silent loss this item is about. - An implementation of the criteria above alone gives "empty response", "unexpected response shape" and "malformed JSON" for 0, 1 and 2 matching events.
Two more gaps let a short listing through:
- the page cap (
while page <= max_pages,rate_limiter.py:1612,:1639) ends as if the listing were complete; - the reader assumes 100 items per page (
_extract_page_per_page,:1514), but_build_paginated_url(:1524) never sendsper_page, so reviews (pr_monitor.py:495) and the timeline stop after GitHub's default of 30.
#983 is open in the backlog, not in v0.2.28, so this item is the only scheduled fix.
Added acceptance criteria:
- A paged read (
run_ghwith--paginate) that also carries-q/--jq,-t/--template,-i/--includeor--silentis refused before any request. It exits non-zero, and stderr names the flag. The flags are detected withrequest_classifier's existinggh apiargparse parser, not a new string check. -
_query_timeline_copilot_statestops using--jq.- It reads
issues/{n}/timeline?per_page=100as a JSON listing and filters the Copilot andreviewedevents in Python, taking the author fromactor.loginoruser.login. - The jq-shaped NDJSON fixtures in
tests/test_github_pr_monitor.py(around:248and:305, and the human-review case around:851) become raw timeline JSON. - Test: a two-page timeline whose matching event is on page 2 gives the right Copilot state.
- It reads
- A listing that is still full when it reaches
DEFAULT_GH_MAX_PAGINATED_PAGESis a failed read that names the cap, as feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740's_read_listingdoes. It is no longer returned as complete. - Every page URL carries
per_page, defaulting toDEFAULT_GH_REST_PER_PAGEwhen the caller gave none, so the short-page rule matches the server's page size. -
devops gh api graphql --paginateis a query, so it takes the paged path. It is refused with a message that names GraphQL; today it returns page 1's object.
Notes for the implementer:
extract_json_payloadhas nine more callers ingithub/projects.py(:378through:1453). Keep the function, and stop using it only to salvage paginated pages.- Each
devops pr waitpoll now reads every timeline page, not just page 1. That is two pages for a release PR with about 110 events.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
The acceptance criteria were amended on 2026-10-08 (see "Update 2026-10-08" at the end of the body). Implementing only the original criteria breaks
devops pr waitanddevops pr monitor, because the Copilot timeline read pages with--jq, which every page would now fail on, so no PR is ever reported ready. Branchfix/1034-paginated-gh-api-fails-closedfollows the original criteria only. Please pick up the added criteria before opening the PR.fix(github): a paginated gh api read fails closed on a page that is n…
dan-petty-bot commentedon Oct 8, 2026
What changed
#1406, merged into
release/v0.2.29as ae9e3b1.8 file(s) changed.
How it was verified
Check runs at 064da1f:
Acceptance Criteria of
docs/agent/tasks/task-1034-paginated-gh-api-read-fails-closed.md:run_ghreturns a non-zero result whose stderr names the endpoint and the page. A literal[]page still ends a listing normally.extract_json_payloadis not used to salvage a paginated page: a page with a preamble before its JSON is a failed read.run_ghwithrun_subprocessstubbed: an HTML page, an empty page, a truncated body and an error object, each on page 1 and on a later page, give a failed read naming the page; a normal listing that ends with[]or a short page still succeeds. Offline, each well under 1 s.devops pr check-readinessreport the read failure instead of evaluating the first page's checks.run_ghwith--paginate) carrying-q/--jq,-t/--template,-i/--includeor--silentis refused before any request, exiting non-zero and naming the flag in stderr._query_timeline_copilot_statestops using--jq, queriesissues/{n}/timeline?per_page=100, and filters events in Python usingactor.loginoruser.login.tests/test_github_pr_monitor.pyupdated to raw JSON array fixtures.DEFAULT_GH_MAX_PAGINATED_PAGESfails closed naming the cap.per_page, defaulting toDEFAULT_GH_REST_PER_PAGE(100) when omitted.devops gh api graphql --paginateis classified as a query taking the paged path, and is refused with a message naming GraphQL.changelog.d/1034.mdrecords the fix under### Fixed.CHANGELOG.mdis not edited.uv run devops cipasses.feat(release): v0.2.29 (#1455)
feat(github): the github session reads rest listings page by page, fo…
feat(release): v0.2.37 (#1720)