Skip to content

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

Closed

Description

@dan-petty

Problem Description

Since #5070, devops gh api <endpoint> --paginate reads a REST GET through the GitHub session. gh adds per_page=100 to a paginated REST read when the endpoint has no per_page (addPerPage in pkg/cmd/api; the installed gh binary holds the symbol github.com/cli/cli/v2/pkg/cmd/api.addPerPage). The session path does not add it. GitHub then sends its default page size of 30. This gives 3 problems:

  1. A read with no per_page sends about 3.3 times more requests than the gh path did.
  2. The --jq output of each page is different from gh's output, because the pages are different.
  3. GitHubSession._follow raises listing_past_page_cap after DEFAULT_GH_MAX_PAGINATED_PAGES (100) pages. At 30 items for each page, a listing of more than 3,000 items now fails with GitHubUnreadError. gh read it in pages of 100. For example, repos/dan-petty/devops-cli/issues?state=all holds about 5,000 items: about 170 pages of 30, but about 51 pages of 100.

In src/devops_cli/github/api_pages.py, listing_text sends session_path(endpoint) with no change, and session_path only adds a leading slash. RestTransport.read_page and SessionGitHubAPI.read_page add no per_page. The module docstring and the github-api-metrics requirement say that the pages print as gh prints them. The tests and the live check of #5070 always give per_page (1 or 100), so they did not find this difference.

Reproduction Steps

  1. On main at 8a7b113, run devops gh api 'repos/dan-petty/devops-cli/labels' --paginate --jq length.
  2. Run the same command at 16356d8, before fix(github): count each page of a paginated GitHub read #5070 (the gh path).

Expected vs Actual Behavior

Expected: the session path sends per_page=100 when the endpoint query has no per_page, as gh does. The command prints 95 from 1 request.

Actual: the command prints 30, 30, 30 and 5 from 4 requests. The output with no filter is the same on both paths (95 items).

Fix: in session_path (or listing_text), add per_page=DEFAULT_GH_REST_PER_PAGE when the query has no per_page. Read and write the query with urllib.parse, not with string checks. Add a command test that reads an endpoint with no per_page and asserts that the first request URL holds per_page=100. Add the rule to the requirement "A paginated devops gh api read of a REST GET counts each page".

Environment Diagnostics

devops-cli main at 8a7b113 (2026-11-12), devcontainer, the installed gh binary, jq.py 1.13.0.

Logs, Traces, or Terminal Output

$ devops gh api 'repos/dan-petty/devops-cli/labels' --paginate --jq length   # main, session path
30
30
30
5
$ devops gh api 'repos/dan-petty/devops-cli/labels' --paginate --jq length   # before #5070, gh path
95

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #5070

Activity

  1. added
    type/bug
    source/agent
    scope/github
    status/new
    value/high
    effort/low
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p1-high
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 12, 2026
  4. removed
    status/in-progress
    owner/agent
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor
  6. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 17:00 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p1-highscope/githubsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions