From 7281a8e93c792fdcd81991327d5462c14028983d Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Thu, 12 Nov 2026 16:25:36 +0000 Subject: [PATCH 1/2] fix(github): a paginated devops gh api read sends per_page=100 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. --- ...b-session-requests-go-through-gidgethub.md | 2 +- .../.openspec.yaml | 2 + .../design.md | 15 ++++++ .../proposal.md | 38 ++++++++++++++ .../specs/github-api-metrics/spec.md | 26 ++++++++++ .../tasks.md | 19 +++++++ src/devops_cli/github/api_pages.py | 25 +++++++-- tests/commands/test_gh_cmd.py | 49 ++++++++++++++++++ tests/github/test_github_api_pages.py | 51 +++++++++++++++++++ 9 files changed, 223 insertions(+), 4 deletions(-) create mode 100644 openspec/changes/5100-a-paginated-devops-gh-api-read/.openspec.yaml create mode 100644 openspec/changes/5100-a-paginated-devops-gh-api-read/design.md create mode 100644 openspec/changes/5100-a-paginated-devops-gh-api-read/proposal.md create mode 100644 openspec/changes/5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md create mode 100644 openspec/changes/5100-a-paginated-devops-gh-api-read/tasks.md diff --git a/docs/adr/0006-github-session-requests-go-through-gidgethub.md b/docs/adr/0006-github-session-requests-go-through-gidgethub.md index 55e068a0a2..a98bcca979 100644 --- a/docs/adr/0006-github-session-requests-go-through-gidgethub.md +++ b/docs/adr/0006-github-session-requests-go-through-gidgethub.md @@ -26,5 +26,5 @@ The process's GitHub session (#767) sends its own REST requests through gidgethu - gidgethub is async only. Every synchronous caller goes through the session's portal, and no caller creates an event loop of its own. - Every `GitHubClient` call (a pull request, its files and diff, a file at a commit, a merge base, an organization's repositories and an issue comment) and SSH key registration (the authentication key and the signing key) are session requests. None builds its own client or reads a `Location` header. A redirect to github.com, which the old diff code followed with the token copied onto it, is now refused. - Tests fake the session through the repository's HTTP transport seam, the one the `web` fixture uses. The `github_api` fixture installs `GitHubApiFake` (`tests/support/fakes/github.py`), a fake GitHub API on `httpx2.MockTransport`, with `install_transport` in place of the transport the entry point would build, and its contract suite holds it to GitHub's recorded answers. The entry point, its timeouts, the redirect handling and the origin hook stay real, and every request is still vetted at the egress level the entry point was asked for. The plan gave the session constructor a `transport=` argument instead. That was dropped: it needed a path around egress vetting in product code, used only by tests. -- `run_gh` no longer pages. The project's own listings (a pull request's files, reviews, timeline and check runs, the reconcile listings, and the roadmap store's REST listings) read through `paginate()`; the roadmap store keeps gh for its board commands. `devops gh api --paginate` reads a REST GET of a path through `pages()`, which gives each page whole, so each page counts as one request with its status (#4737). Its `--jq` filter runs on each page through jq.py, as gh runs it. gh keeps the other paginated reads of `devops gh api`: GraphQL, a write, a gh placeholder, a full URL, `--template`, `--cache` and any other gh flag, such as `--slurp`. `run_gh` hands gh those flags as given, since gh follows `Link` itself. gh walks the pages in one process, so the whole walk runs under one timeout (`DEFAULT_GH_API_PAGINATE_TIMEOUT_SECONDS`), counts as one request, and a rate-limited walk is retried from page 1. The metrics row reads open issues with `GhCliClient.api(paginate=True)` until #3941 moves that read. `run_gh_async` and its `aiolimiter` limiter are gone. +- `run_gh` no longer pages. The project's own listings (a pull request's files, reviews, timeline and check runs, the reconcile listings, and the roadmap store's REST listings) read through `paginate()`; the roadmap store keeps gh for its board commands. `devops gh api --paginate` reads a REST GET of a path through `pages()`, which gives each page whole, so each page counts as one request with its status (#4737). It adds `per_page=100` when the endpoint does not set `per_page`, as gh adds it, so it reads the pages that gh reads (#5100). Its `--jq` filter runs on each page through jq.py, as gh runs it. gh keeps the other paginated reads of `devops gh api`: GraphQL, a write, a gh placeholder, a full URL, `--template`, `--cache` and any other gh flag, such as `--slurp`. `run_gh` hands gh those flags as given, since gh follows `Link` itself. gh walks the pages in one process, so the whole walk runs under one timeout (`DEFAULT_GH_API_PAGINATE_TIMEOUT_SECONDS`), counts as one request, and a rate-limited walk is retried from page 1. The metrics row reads open issues with `GhCliClient.api(paginate=True)` until #3941 moves that read. `run_gh_async` and its `aiolimiter` limiter are gone. - A failed gh command is classified in the same module, `classify_gh_failure`, from gh's exit status (4 is "requires authentication") and the gh-output table in `config/constants.py`, matched against what gh wrote to stderr, never GitHub's answer on stdout. The table is the one place gh's failures are classified by gh's text; `_is_branch_unprotected_error`, `create_repository_issue`, `_report_create_failure` and `extract_retry_after` still match gh's text of their own. Its errors carry the status gh names as an int, like an HTTP failure's. `graphql()` waits for the first item that moves a GraphQL call off gh. diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/.openspec.yaml b/openspec/changes/5100-a-paginated-devops-gh-api-read/.openspec.yaml new file mode 100644 index 0000000000..55ab199b3d --- /dev/null +++ b/openspec/changes/5100-a-paginated-devops-gh-api-read/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-11-12 diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/design.md b/openspec/changes/5100-a-paginated-devops-gh-api-read/design.md new file mode 100644 index 0000000000..8e3a6a2a81 --- /dev/null +++ b/openspec/changes/5100-a-paginated-devops-gh-api-read/design.md @@ -0,0 +1,15 @@ +# Design + +## Decisions + +- **Add the page size in `session_path`.** The read (`listing_text`) and the dry-run plan of `devops gh api --paginate` both use `session_path`, so the plan names the URL that the read sends. `GitHubSession.pages()` stays a reader of the path it gets: the rule is a rule of `gh api`, not of the session. +- **Copy each step of `addPerPage` (gh v2.103.1, `pkg/cmd/api/pagination.go`).** The path splits at its first `?`, as `strings.IndexRune` splits it. `urllib.parse.parse_qs` with `keep_blank_values=True` reads the query, and the check takes the first value of `per_page`, as Go's `url.Values.Get` gives it. A first value that is empty, or a `per_page` with no `=`, does not count as set, as in gh. The pair goes after `&` when the path has a `?`, else after `?`, so the path is the path of gh, also for an endpoint that ends in `?`. `urlencode` writes the pair. +- **The page size is `DEFAULT_GH_REST_PER_PAGE` (100).** gh writes the same number (`addPerPage(requestPath, 100, params)` in `pkg/cmd/api/api.go`). +- **The `params` step of gh does not apply.** gh keeps a `per_page` given with `-f` or `-F`. `reads_through_session` gives each read with a gh flag to gh, so the session never gets such a read. + +## Rejected alternatives + +- **Read and write the path with `urlsplit` and `urlunsplit`.** `urlunsplit(urlsplit('/repos/o/r/labels?'))` gives `/repos/o/r/labels`: the empty query and its `?` go. The path would then be `labels?per_page=100`, not the `labels?&per_page=100` of gh. `urlsplit` also moves a `#` fragment out of the query, which gh does not do. +- **Copy the parse errors of Go's `url.ParseQuery`.** gh adds `per_page=100` also when Go cannot parse the query (a `;` in it, or a `%` with no two hex digits after it), even when the query sets `per_page`. `parse_qs` reads such a query with no error, so the session keeps the `per_page` of the endpoint there. To copy gh, the module needs a written copy of the parse rules of Go. httpx2 sends such a query as it is typed (`httpx2.URL('https://api.github.com').join('/repos/o/r/issues?q=%zz;x&per_page=5')` keeps it), so the only difference is the second `per_page` that gh appends to an endpoint that sets `per_page` and also holds a query that Go refuses. The cost of a written parser is more than the value for such an endpoint. +- **Use `listing_path` of `roadmap/stores/github_store.py`.** It appends `per_page` to every endpoint after a check for `?` in the text, so an endpoint that sets `per_page` gets a second one. Its callers build the endpoint and know that it sets no `per_page`, so it does not need the rule of gh. +- **Add the page size in `GitHubSession.pages()` or `RestTransport.read_page`.** The session reads the path that its caller gives. A caller that wants another page size would have no way to ask for it, and the rule of `gh api` would move into code that is not about `gh api`. diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/proposal.md b/openspec/changes/5100-a-paginated-devops-gh-api-read/proposal.md new file mode 100644 index 0000000000..be46daec88 --- /dev/null +++ b/openspec/changes/5100-a-paginated-devops-gh-api-read/proposal.md @@ -0,0 +1,38 @@ +# Proposal: #5100 + +## Why + +Since #4737, `devops gh api --paginate` reads a REST GET through the GitHub session. gh adds `per_page=100` to a paginated REST read when the endpoint does not set `per_page`, but the session path sends the endpoint as it is. GitHub then answers with its default page size of 30. A read with no `per_page` sends about 3.3 times more requests than gh, the `--jq` output of each page is different from the output of gh, and a listing of more than 3,000 items stops at the cap of 100 pages with `GitHubUnreadError`, where gh read it in pages of 100. Closes #5100. + +## What Changes + +- `session_path` in `src/devops_cli/github/api_pages.py` adds `per_page=100` (`DEFAULT_GH_REST_PER_PAGE`) to the endpoint when the first `per_page` of its 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 read and its dry-run plan use the same path, so the plan names the URL that the read sends. + +The change alters the requests that a `devops gh api` command sends and the lines that it prints, which a consumer observes, so it has a spec delta. + +## Capabilities + +- `github-api-metrics` (MODIFIED requirement): a paginated `devops gh api` read of a REST GET counts each page, and asks for pages of 100 when the endpoint sets no `per_page`. + +## Impact + +- A paginated read with no `per_page` sends the number of requests that gh sent: for example, about 51 requests for 5,000 issues, not about 170. +- A listing of up to 10,000 items fits in the cap of 100 pages again. +- The `--jq` output of each page is the output of gh, because the pages are the pages of gh. +- The Service runs this code. No setting, manifest or dependency changes. The change fits one pull request. + +## Feasibility + +- Source, gh v2.103.1 `pkg/cmd/api/api.go`: `if opts.Paginate && !isGraphQL { requestPath = addPerPage(requestPath, 100, params) }`. +- Source, gh v2.103.1 `pkg/cmd/api/pagination.go`, `addPerPage`: it returns the path unchanged 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 `?`, or after `?`. +- Command output on main at a04e7a94c (v0.119.0 code), 2026-11-12: `devops gh api 'repos/dan-petty/devops-cli/labels' --paginate --jq length` printed `30`, `30`, `30` and `5` (4 requests). +- Command output, same day, on the gh path (the extra gh flag `-H 'Accept: application/vnd.github+json'` keeps the read with the installed gh): the same read printed `95` (1 request). +- Census, `git grep -n 'session_path(\|listing_text(' -- src`: `commands/gh.py` (2: the dry-run plan and the read) and `github/api_pages.py` (3: the two definitions and the call of `pages`). `GitHubSession.pages()` has one caller, `listing_text`. So the change reaches only `devops gh api --paginate`. + +## Existing Tool Considered + +- gh owns the rule. The session must send the request itself, because a gh walk counts as one request (#4737). The fix copies the rule of gh and cites its source. +- The Python standard library reads the query (`urllib.parse.parse_qs`) and writes the pair (`urllib.parse.urlencode`). +- Built: about 10 lines in `session_path`. Cost: about 60,000 tokens and 1 hour to build, and about 2,000 tokens a year to compare the rule with `addPerPage` when gh changes. +- The change deletes no internal code. diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md b/openspec/changes/5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md new file mode 100644 index 0000000000..cb85186b02 --- /dev/null +++ b/openspec/changes/5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md @@ -0,0 +1,26 @@ +## MODIFIED Requirements + +### Requirement: A paginated devops gh api read of a REST GET counts each page +`devops gh api --paginate` SHALL read a REST GET of a path through the GitHub session, so that each page adds 1 to `devops_cli_github_requests_total` with the status of its answer. The session SHALL add `per_page=100` to the endpoint when the first `per_page` of its query has no value, as gh adds it, so that it reads the pages that gh reads. gh SHALL keep a GraphQL read, a write, an endpoint with a gh placeholder, a full URL, `--template`, `--cache` and any other gh flag. `--jq` SHALL run on each page. + +#### Scenario: A listing of 4 pages +- **WHEN** `devops gh api 'repos///issues?state=open&per_page=1' --paginate` reads 4 linked pages from the GitHub fake +- **THEN** `devops_cli_github_requests_total` has one point with the `resource` `core`, the `status` `200` and the value 4 +- **AND** the output is one JSON array that holds the items of the 4 pages + +#### Scenario: A jq filter on each page +- **WHEN** `devops gh api ... --paginate --jq 'length, .[].number'` reads a page of 2 items and a page of 1 item +- **THEN** the output is the lines `2`, `1`, `2`, `1` and `3` + +#### Scenario: An endpoint with no per_page +- **WHEN** `devops gh api 'repos///labels' --paginate --jq length` reads a listing of 150 labels from the GitHub fake +- **THEN** the first request URL holds `per_page=100` +- **AND** the session sends 2 requests, and the output is the lines `100` and `50` + +#### Scenario: An endpoint that sets per_page +- **WHEN** `devops gh api 'repos///labels?per_page=50' --paginate` runs +- **THEN** the request URL holds `per_page=50` and no other `per_page` + +#### Scenario: A read that gh keeps +- **WHEN** `devops gh api 'repos/:owner/:repo/issues' --paginate` runs +- **THEN** gh gets the argv with `--paginate`, and the GitHub session sends no request diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/tasks.md b/openspec/changes/5100-a-paginated-devops-gh-api-read/tasks.md new file mode 100644 index 0000000000..cd3ebd6d5b --- /dev/null +++ b/openspec/changes/5100-a-paginated-devops-gh-api-read/tasks.md @@ -0,0 +1,19 @@ +# Tasks + +## 1. Behavior: a paginated devops gh api read asks for pages of 100 + +- [x] 1.1 Write failing tests: `session_path` adds `per_page=100` with the rule of gh `addPerPage` and keeps a `per_page` that the endpoint sets + - Verification: `$ uv run devops ci test tests/github/test_github_api_pages.py` +- [x] 1.2 Write failing command tests: 150 labels with no `per_page` take 2 requests of 100 and `--jq length` prints `100` and `50`, an endpoint with `per_page=50` keeps it, and a dry run plans `per_page=100` + - Verification: `$ uv run devops ci test tests/commands/test_gh_cmd.py` +- [x] 1.3 Add the page size in `session_path` + - Verification: `$ uv run devops ci test tests/github/test_github_api_pages.py tests/commands/test_gh_cmd.py` + +## 2. Documents + +- [x] 2.1 State the page size of the session read of `devops gh api --paginate` in ADR 0006 + - Verification: `$ uv run devops ci docs` + +## Workflow follow-up + +- Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD). diff --git a/src/devops_cli/github/api_pages.py b/src/devops_cli/github/api_pages.py index ba3aa6b31a..99a4114050 100644 --- a/src/devops_cli/github/api_pages.py +++ b/src/devops_cli/github/api_pages.py @@ -15,6 +15,10 @@ - a read that `--cache` keeps in the response cache of `run_gh`; - any other gh flag, such as `--slurp`, `-H` or `-f`. +`session_path` asks for pages of 100 items when the endpoint does not set `per_page`, as gh +asks for them (#5100). So the session reads the pages that gh reads, in the same number of +requests. + `printed_pages` prints the pages as gh 2.103.1 prints them. With no filter, the items of array pages print as one JSON array, and each object page prints whole, on its own line. A `--jq` filter runs on each page through jq.py, the Python binding of jq, and each value prints on its @@ -30,14 +34,17 @@ import re from collections.abc import Iterable, Iterator, Sequence from typing import Any, Final -from urllib.parse import urlsplit +from urllib.parse import parse_qs, urlencode, urlsplit from devops_cli.config.constants import CONST_GH_API_DEFAULT_METHOD, CONST_GH_API_GRAPHQL_ENDPOINT +from devops_cli.config.defaults import DEFAULT_GH_REST_PER_PAGE from devops_cli.exceptions.validation import ValidationError _GH_PLACEHOLDER: Final = re.compile(r":(?:owner|repo|branch)\b|\{[a-z]+\}") """The placeholders gh fills from its base repository (gh 2.103.1, `fillPlaceholders`).""" +_PER_PAGE: Final = "per_page" + # gh prints a number that a filter selects with no decimals when it is whole, else with two. _WHOLE_NUMBER_FORMAT: Final = ".0f" _FRACTION_FORMAT: Final = ".2f" @@ -68,8 +75,20 @@ def reads_through_session( def session_path(endpoint: str) -> str: """The path of `endpoint` under GitHub's API, with or without its leading slash, as gh - reads it.""" - return "/" + endpoint.lstrip("/") + reads it, with the page size gh asks for. + + gh 2.103.1 adds `per_page=100` to a paginated REST read when the first `per_page` of its + query has no value (`addPerPage` in `pkg/cmd/api/pagination.go`, #5100): after `&` when the + endpoint has a `?`, else after `?`. gh also keeps a `per_page` given with `-f` or `-F`, but + such a read has a gh flag, so gh sends it. + """ + path = "/" + endpoint.lstrip("/") + _, question_mark, query = path.partition("?") + # The first value, as Go's `url.Values.Get` gives it to gh. + if parse_qs(query, keep_blank_values=True).get(_PER_PAGE, [""])[0]: + return path + page_size = urlencode({_PER_PAGE: DEFAULT_GH_REST_PER_PAGE}) + return f"{path}{'&' if question_mark else '?'}{page_size}" def listing_text(endpoint: str, jq_filter: str | None) -> Iterator[str]: diff --git a/tests/commands/test_gh_cmd.py b/tests/commands/test_gh_cmd.py index cfa8123972..387c415635 100644 --- a/tests/commands/test_gh_cmd.py +++ b/tests/commands/test_gh_cmd.py @@ -1073,6 +1073,55 @@ def test_gh_api_paginate_runs_the_jq_filter_on_each_page(github_api: GitHubApiFa assert (result.exit_code, result.output) == (0, "2\n1\n2\n1\n3\n") +def test_gh_api_paginate_reads_pages_of_100_as_gh_does(github_api: GitHubApiFake) -> None: + """An endpoint with no `per_page` is read in pages of 100, as gh adds `per_page=100`: 150 + labels take 2 requests, and `--jq length` prints one line for each page, as gh prints + them (#5100).""" + first, second = ( + "/repos/octo/repo/labels?per_page=100", + "/repositories/1/labels?per_page=100&page=2", + ) + labels = [{"id": n} for n in range(150)] + github_api.route("GET", first, github_json(labels[:100], headers=next_page(second))) + github_api.route("GET", second, github_json(labels[100:])) + + result = runner.invoke(app, ["api", "repos/octo/repo/labels", "--paginate", "--jq", "length"]) + + assert (result.exit_code, result.output, github_api.requested) == ( + 0, + "100\n50\n", + [ + "GET https://api.github.com/repos/octo/repo/labels?per_page=100", + "GET https://api.github.com/repositories/1/labels?per_page=100&page=2", + ], + ) + + +def test_gh_api_paginate_keeps_the_per_page_of_the_endpoint(github_api: GitHubApiFake) -> None: + """An endpoint that sets `per_page` is read with its own page size only (#5100).""" + github_api.route("GET", "/repos/octo/repo/labels?per_page=50", github_json([{"id": 1}])) + + argv = ["api", "repos/octo/repo/labels?per_page=50", "--paginate", "--jq", "length"] + result = runner.invoke(app, argv) + + assert (result.exit_code, result.output, github_api.requested) == ( + 0, + "1\n", + ["GET https://api.github.com/repos/octo/repo/labels?per_page=50"], + ) + + +def test_gh_api_paginate_dry_run_plans_pages_of_100(github_api: GitHubApiFake) -> None: + """A dry run plans the first page with the `per_page=100` that the read sends (#5100).""" + result = runner.invoke(app, ["api", "repos/octo/repo/labels", "--paginate", "--dry-run"]) + + assert ( + result.exit_code, + "/repos/octo/repo/labels?per_page=100" in _flat(result.output), + github_api.sent, + ) == (0, True, []) + + def test_gh_api_paginate_exits_1_naming_a_listing_github_does_not_find( github_api: GitHubApiFake, ) -> None: diff --git a/tests/github/test_github_api_pages.py b/tests/github/test_github_api_pages.py index 051895ce98..75283d4abc 100644 --- a/tests/github/test_github_api_pages.py +++ b/tests/github/test_github_api_pages.py @@ -63,6 +63,57 @@ def test_the_session_path_of_an_endpoint_starts_at_the_api_root(endpoint: str) - assert session_path(endpoint) == "/" + _LISTING +@pytest.mark.parametrize( + ("endpoint", "path"), + [ + pytest.param( + "repos/octo/repo/labels", "/repos/octo/repo/labels?per_page=100", id="no-query" + ), + pytest.param( + "repos/octo/repo/issues?state=all", + "/repos/octo/repo/issues?state=all&per_page=100", + id="query", + ), + pytest.param( + "repos/octo/repo/labels?", "/repos/octo/repo/labels?&per_page=100", id="empty" + ), + pytest.param( + "repos/octo/repo/issues?per_page=", + "/repos/octo/repo/issues?per_page=&per_page=100", + id="per-page-empty", + ), + pytest.param( + "repos/octo/repo/issues?per_page&state=all", + "/repos/octo/repo/issues?per_page&state=all&per_page=100", + id="per-page-with-no-value", + ), + pytest.param( + "repos/octo/repo/issues?per_page=&per_page=5", + "/repos/octo/repo/issues?per_page=&per_page=5&per_page=100", + id="first-per-page-empty", + ), + ], +) +def test_a_read_with_no_per_page_asks_for_pages_of_100_as_gh_does(endpoint: str, path: str) -> None: + """gh adds `per_page=100` to a paginated REST read when the first `per_page` of its query + has no value, after `&` when the endpoint has a `?`, else after `?` (#5100).""" + assert session_path(endpoint) == path + + +@pytest.mark.parametrize( + "endpoint", + [ + "/repos/octo/repo/issues?per_page=5", + "/repos/octo/repo/issues?state=all&per_page=5", + "/repos/octo/repo/issues?per%5Fpage=5", + "/search/issues?q=a+b&per_page=5&per_page=", + ], +) +def test_an_endpoint_that_sets_per_page_keeps_it(endpoint: str) -> None: + """A query whose first `per_page` has a value, also an escaped name, is sent as it is.""" + assert session_path(endpoint) == endpoint + + def test_array_pages_print_as_one_json_array() -> None: """With no filter, the items of all array pages print as one compact JSON array, as gh joins them.""" From 94eba5b5218ab5bf9c17f015ae4e20531dc052ec Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Thu, 12 Nov 2026 16:27:28 +0000 Subject: [PATCH 2/2] docs(openspec): archive 5100-a-paginated-devops-gh-api-read --- .../.openspec.yaml | 0 .../design.md | 0 .../proposal.md | 0 .../specs/github-api-metrics/spec.md | 2 +- .../tasks.md | 0 openspec/specs/github-api-metrics/spec.md | 11 ++++++++++- 6 files changed, 11 insertions(+), 2 deletions(-) rename openspec/changes/{5100-a-paginated-devops-gh-api-read => archive/2026-11-12-5100-a-paginated-devops-gh-api-read}/.openspec.yaml (100%) rename openspec/changes/{5100-a-paginated-devops-gh-api-read => archive/2026-11-12-5100-a-paginated-devops-gh-api-read}/design.md (100%) rename openspec/changes/{5100-a-paginated-devops-gh-api-read => archive/2026-11-12-5100-a-paginated-devops-gh-api-read}/proposal.md (100%) rename openspec/changes/{5100-a-paginated-devops-gh-api-read => archive/2026-11-12-5100-a-paginated-devops-gh-api-read}/specs/github-api-metrics/spec.md (83%) rename openspec/changes/{5100-a-paginated-devops-gh-api-read => archive/2026-11-12-5100-a-paginated-devops-gh-api-read}/tasks.md (100%) diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/.openspec.yaml b/openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/.openspec.yaml similarity index 100% rename from openspec/changes/5100-a-paginated-devops-gh-api-read/.openspec.yaml rename to openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/.openspec.yaml diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/design.md b/openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/design.md similarity index 100% rename from openspec/changes/5100-a-paginated-devops-gh-api-read/design.md rename to openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/design.md diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/proposal.md b/openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/proposal.md similarity index 100% rename from openspec/changes/5100-a-paginated-devops-gh-api-read/proposal.md rename to openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/proposal.md diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md b/openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md similarity index 83% rename from openspec/changes/5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md rename to openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md index cb85186b02..61f9579709 100644 --- a/openspec/changes/5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md +++ b/openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/specs/github-api-metrics/spec.md @@ -1,7 +1,7 @@ ## MODIFIED Requirements ### Requirement: A paginated devops gh api read of a REST GET counts each page -`devops gh api --paginate` SHALL read a REST GET of a path through the GitHub session, so that each page adds 1 to `devops_cli_github_requests_total` with the status of its answer. The session SHALL add `per_page=100` to the endpoint when the first `per_page` of its query has no value, as gh adds it, so that it reads the pages that gh reads. gh SHALL keep a GraphQL read, a write, an endpoint with a gh placeholder, a full URL, `--template`, `--cache` and any other gh flag. `--jq` SHALL run on each page. +`devops gh api --paginate` SHALL read a REST GET of a path through the GitHub session, so that each page adds 1 to `devops_cli_github_requests_total` with the status of its answer. The session SHALL add `per_page=100` when the endpoint sets no `per_page`, as gh does. gh SHALL keep a GraphQL read, a write, an endpoint with a gh placeholder, a full URL, `--template`, `--cache` and any other gh flag. `--jq` SHALL run on each page. #### Scenario: A listing of 4 pages - **WHEN** `devops gh api 'repos///issues?state=open&per_page=1' --paginate` reads 4 linked pages from the GitHub fake diff --git a/openspec/changes/5100-a-paginated-devops-gh-api-read/tasks.md b/openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/tasks.md similarity index 100% rename from openspec/changes/5100-a-paginated-devops-gh-api-read/tasks.md rename to openspec/changes/archive/2026-11-12-5100-a-paginated-devops-gh-api-read/tasks.md diff --git a/openspec/specs/github-api-metrics/spec.md b/openspec/specs/github-api-metrics/spec.md index 90cdf0ca9c..3a7c8292fd 100644 --- a/openspec/specs/github-api-metrics/spec.md +++ b/openspec/specs/github-api-metrics/spec.md @@ -93,7 +93,7 @@ The rate limiter SHALL log each mandatory pause and each quota window reset at D - **THEN** the pause record has level DEBUG, and no record of that pause has level INFO. ### Requirement: A paginated devops gh api read of a REST GET counts each page -`devops gh api --paginate` SHALL read a REST GET of a path through the GitHub session, so that each page adds 1 to `devops_cli_github_requests_total` with the status of its answer. gh SHALL keep a GraphQL read, a write, an endpoint with a gh placeholder, a full URL, `--template`, `--cache` and any other gh flag. `--jq` SHALL run on each page. +`devops gh api --paginate` SHALL read a REST GET of a path through the GitHub session, so that each page adds 1 to `devops_cli_github_requests_total` with the status of its answer. The session SHALL add `per_page=100` when the endpoint sets no `per_page`, as gh does. gh SHALL keep a GraphQL read, a write, an endpoint with a gh placeholder, a full URL, `--template`, `--cache` and any other gh flag. `--jq` SHALL run on each page. #### Scenario: A listing of 4 pages - **WHEN** `devops gh api 'repos///issues?state=open&per_page=1' --paginate` reads 4 linked pages from the GitHub fake @@ -104,6 +104,15 @@ The rate limiter SHALL log each mandatory pause and each quota window reset at D - **WHEN** `devops gh api ... --paginate --jq 'length, .[].number'` reads a page of 2 items and a page of 1 item - **THEN** the output is the lines `2`, `1`, `2`, `1` and `3` +#### Scenario: An endpoint with no per_page +- **WHEN** `devops gh api 'repos///labels' --paginate --jq length` reads a listing of 150 labels from the GitHub fake +- **THEN** the first request URL holds `per_page=100` +- **AND** the session sends 2 requests, and the output is the lines `100` and `50` + +#### Scenario: An endpoint that sets per_page +- **WHEN** `devops gh api 'repos///labels?per_page=50' --paginate` runs +- **THEN** the request URL holds `per_page=50` and no other `per_page` + #### Scenario: A read that gh keeps - **WHEN** `devops gh api 'repos/:owner/:repo/issues' --paginate` runs - **THEN** gh gets the argv with `--paginate`, and the GitHub session sends no request