Skip to content

fix(github): a paginated devops gh api read sends per_page=100 - #5141

Merged
dan-petty merged 2 commits into
mainfrom
fix/5100-a-paginated-devops-gh-api-read
Nov 12, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/5100-a-paginated-devops-gh-api-read

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Since #4737, devops gh api --paginate reads a REST GET through the GitHub session. The session sent the endpoint with no per_page, so GitHub sent pages of 30, not the pages of 100 that gh reads. A read sent about 3.3 times more requests, the --jq output of each page was different from gh, and a listing of more than 3,000 items stopped at the cap of 100 pages.

session_path now adds per_page=100 when the first per_page of the query has no value, with the rule of gh 2.103.1 (addPerPage in pkg/cmd/api/pagination.go). An endpoint that sets per_page keeps it. The dry-run plan names the same URL.

Closes #5100

Change: openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/

A paginated devops gh api read of a REST GET goes through the GitHub session. The session sent the endpoint with no per_page, so GitHub sent pages of 30. session_path now adds per_page=100 when the first per_page of the query has no value, with the rule of gh 2.103.1 (addPerPage in pkg/cmd/api/pagination.go). An endpoint that sets per_page keeps it.
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/github GitHub Projects v2, Views, Milestones, Labels, and PR automation labels Nov 12, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Merge gate: the roadmap Service runs this code (devops gh api --paginate is on the session path since v0.119.0). Merge only after the owner says that the change is safe and vetted.

gh rule matched (gh v2.103.1): pkg/cmd/api/api.go calls addPerPage(requestPath, 100, params) when opts.Paginate && !isGraphQL. addPerPage in pkg/cmd/api/pagination.go keeps the path when params holds per_page, or when the text after the first ? parses with url.ParseQuery and Get("per_page") is not empty. Else it appends per_page=100 after & when the path has a ?, else after ?. session_path copies each step: split at the first ?, parse_qs(keep_blank_values=True) and the first value (as url.Values.Get), the same separator. The params step does not apply, because a read with -f or -F stays with gh.

One branch not copied: gh also appends per_page=100 when Go cannot parse the query (a ;, or a % with no two hex digits after it), even when the query sets per_page. parse_qs reads such a query, so the session keeps the per_page of the endpoint there. To copy it needs a written copy of Go's parse rules. The design records the evidence.

fail-to-pass: uv run devops ci fail-to-pass --base origin/main exit 0: 8 failed on base, all 118 tests of the 2 files pass on head.

failed on base: tests.github.test_github_api_pages::test_a_read_with_no_per_page_asks_for_pages_of_100_as_gh_does[no-query|query|empty|per-page-empty|per-page-with-no-value|first-per-page-empty]
failed on base: tests.commands.test_gh_cmd::test_gh_api_paginate_reads_pages_of_100_as_gh_does
failed on base: tests.commands.test_gh_cmd::test_gh_api_paginate_dry_run_plans_pages_of_100
8 failed on base (8 failed and 110 passed in tests/commands/test_gh_cmd.py, tests/github/test_github_api_pages.py; 0 errored).

Local checks (after the rebase on b1a798c): uv run devops ci --check --only lint,format,docs,constructs,openspec,test-tree all pass. uv run devops ci test tests/github/test_github_api_pages.py tests/commands/test_gh_cmd.py tests/github/test_github_session.py: 198 passed. mypy src/devops_cli/github/api_pages.py: no issues. Related GitHub suites (client, metrics, rate limiter, session, dry-run plans): 402 passed.

Live check, 2026-11-12:

  • Before (main at a04e7a9): devops gh api 'repos/dan-petty/devops-cli/labels' --paginate --jq length printed 30, 30, 30, 5 (4 requests). The same read on the gh path (an extra -H flag) printed 95 (1 request).
  • After (this branch): the same read printed 95 (1 request). With ?per_page=50 it printed 50, 45, so the page size of the endpoint stays.

Observed live impact (reported by the operator, not measured in this change): the Service request budget went from a peak of 1918 to 2323 in the hour after the v0.119.0 rollout (limit 4000).

@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 16:33
@dan-petty
dan-petty enabled auto-merge (squash) November 12, 2026 16:34
@dan-petty
dan-petty disabled auto-merge November 12, 2026 16:37
@dan-petty
dan-petty merged commit 621f24c into main Nov 12, 2026
24 checks passed
@dan-petty
dan-petty deleted the fix/5100-a-paginated-devops-gh-api-read branch November 12, 2026 16:38
dan-petty pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.120.1](v0.120.0...v0.120.1)
(2026-11-12)


### Bug Fixes

* **github:** a paginated devops gh api read sends per_page=100
([#5141](#5141))
([621f24c](621f24c))
* **pr:** pr create fits a repository without openspec
([#5142](#5142))
([aed68b3](aed68b3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/github GitHub Projects v2, Views, Milestones, Labels, and PR automation type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(github): a paginated devops gh api read sends per_page=100 as gh does

1 participant