Repository navigation
Description
Is your feature request related to a problem? Please describe.
One plumber analyze on a GitHub repository sends a lot of REST requests, and we hit the rate limit too often. Every request goes out one at a time through go-gh api.RESTClient. There is no GraphQL, no response cache, no conditional request (ETag), and nothing reads x-ratelimit-remaining or retry-after. On top of that, several resources are fetched more than once in the same run.
Most of the cost scales with the number of distinct action references (owner/repo@ref, direct and nested). Each one costs about 4–6 REST calls.
Every GitHub request in one analyze
Variables: R = distinct action repos, A = distinct owner/repo@ref refs (direct and nested), K = distinct action containers (owner/repo/subpath@ref), T = third-party containers, C = steps with a # vX.Y.Z comment, W = workflow files.
Action metadata (enrichActions, github/github_workflows.go:299). This runs unless all 10 consumer controls are benched in code. Disabling them in .plumber.yaml does not skip it.
| # | Request | Where | Used for | How often |
|---|---|---|---|---|
| M1 | GET repos/{o}/{r} |
github_metadata.go:901 |
archived, stars, full name (ISSUE-702, 713) | per repo, cached |
| M2 | GET repos/{o}/{r}/releases?per_page=50 (1–3 pages) |
github_metadata.go:944 |
latest semver release (ISSUE-709) | per repo, cached |
| M3 | GET repos/{o}/{r}/git/ref/tags/{latest} (+ git/tags/{sha} if annotated) |
github_metadata.go:317 |
SHA of the latest release | per ref, resolveTag has no cache |
| M4 | GET advisories?ecosystem=actions&affects={o}/{r} |
github_metadata.go:545 |
advisories (ISSUE-703) | per repo, cached |
| M5 | GET repos/{o}/{r}/tags?per_page=100 (up to 20 pages, retried anonymously on 403) |
github_metadata.go:776 |
SHA → version for advisory ranges | per SHA-pinned repo with advisories |
| M6 | GET repos/{o}/{r}/git/ref/tags/{ref} (+ git/tags/{sha}) |
github_metadata.go:328 |
is the ref a tag (ISSUE-701, 402, 401) | per ref |
| M7 | GET repos/{o}/{r}/branches/{ref} |
github_metadata.go:1152 |
is the ref a branch, ambiguity (ISSUE-402) | per ref |
| M8 | GET repos/{o}/{r}/releases/tags/{ref} |
github_metadata.go:1198 |
immutable release (ISSUE-701) | per tag ref |
| M9 | GET repos/{o}/{r}/commits/{ref} |
github_metadata.go:1168 |
commit exists (ISSUE-707) | per SHA pin |
| M10 | GET repos/{o}/{r}/git/tags/{sha} (up to 4) + M9 |
github_metadata.go:1099, 1123 |
SHA pin that names a tag object (ISSUE-401) | only when M9 answers 404/422 |
| M11 | GET repos/{o}/{r}/git/ref/tags/{commentVersion} (+ git/tags) |
github_workflows.go:360 |
pin comment matches SHA | per step occurrence, no cache |
When ref equals the latest release tag, M3 and M6 fetch the same URL twice in a row.
Action and workflow definitions (resolveNestedActions, github/nested_actions.go:993). These always run.
| # | Request | Where | How often |
|---|---|---|---|
| D1 | raw action.yml, then action.yaml |
nested_actions.go:268 |
per container K |
| D2 | raw reusable workflow file from another repo | nested_workflows.go:88 |
per distinct workflow |
| — | GET repos/{o}/{r}/contents/{path}?ref= fallback |
nested_actions.go:207 (readWith) |
after every raw miss, including a plain 404 |
ISSUE-714 mutable remote exec (github/action_source.go:1046), when the control is enabled. For each third-party container it reads the main entrypoint, then every candidate (action.js, index.js, dist/index.js, src/index.js) without stopping at the first hit (action_source.go:976). Each missing candidate costs one raw 404 and one Contents API 404. A typical dist/index.js action costs 3 raw + 3 REST 404s.
Scanned repo (once per analyze, control/task_github.go:508, :664)
| # | Request | Where | Note |
|---|---|---|---|
| R1 | GET repos/{o}/{r} |
github_branch_protection.go:380 |
default branch |
| R2 | GET repos/{o}/{r} |
github_branch_protection.go:411 |
visibility, full name: same call as R1 |
| R3 | GET repos/{o}/{r} |
github_branch_protection.go:443 |
third copy, when zero branches come back |
| R4 | GET repos/{o}/{r}/environments?per_page=30 (paged) |
github_environments.go:77 |
per_page could be 100 |
| R5 | GET repos/{o}/{r}/actions/workflows?per_page=100 (paged) |
github_workflow_states.go:57 |
|
| R6–R9 | actions/runs, runs/{id}/jobs (×3), jobs/{id}/logs, releases?per_page=20 |
github_token_default.go:307-492 |
default GITHUB_TOKEN permissions |
| B1 | GET repos/{o}/{r}/branches/{name} |
github_branch_protection.go:263 |
default config: main, master, production, dev and the default branch |
| B2 | GET repos/{o}/{r}/branches/{name}/protection |
github_branch_protection.go:548 |
per protected branch |
| B3 | GET repos/{o}/{r}/rules/branches/{name} (paged) |
github_branch_protection.go:468 |
per protected branch |
| B4 | GET repos/{o}/{r}/branches?per_page=100 (paged) |
github_branch_protection.go:529 |
when a pattern is a glob (release/* by default) |
Every lane function builds a new REST client (newGitHubRESTClient, github_workflows_remote.go:165).
Remote mode only (--project): one Contents listing of .github/workflows, one Contents call per workflow file (W), and Contents calls for local ./ composites. A 404 on the listing adds another GET repos/{o}/{r} and commits/{ref}.
Rough total for a SHA-pinned repo with no advisories: about 3R + 4–5A + C REST calls for metadata, plus about 10 for the scanned repo and branch protection, plus one REST call for every raw miss. ISSUE-714 adds about 3–4T REST calls.
Describe the solution you'd like
Get the same information with fewer requests, in line with GitHub's REST best practices:
- Fetch the scanned repo once. R1, R2 and R3 (and W2 in remote mode) should share one
GET repos/{o}/{r}, and one REST client per run. - Cache
resolveTagperowner/repo@tag. That removes the per-ref M3, the M3/M6 double fetch, and the per-occurrence M11. - Batch the per-ref probes in GraphQL. M1, M2/M3 and M6–M10 are single-object lookups (repo fields, tag ref, branch ref, commit by SHA, release by tag). One GraphQL query with aliases can answer them for many refs at once (
repository { isArchived stargazerCount nameWithOwner },ref(qualifiedName: "refs/tags/…"),ref(qualifiedName: "refs/heads/…"),object(oid: …),release(tagName: …)). GraphQL also has its own budget, separate from REST. We need to check field by field that GraphQL exposes what each control needs (for example the immutable-release flag); anything it doesn't expose stays on REST. - Stop the Contents API fallback after a definitive raw 404. Today every raw miss costs one more REST call. For ISSUE-714, stop at the first entrypoint candidate found, or list the action directory once instead of probing each candidate.
- Use conditional requests (best practice). A
304doesn't count against the primary rate limit. go-gh can cache responses (EnableCache/CacheTTLinapi.ClientOptions), and we never turn it on. Tag refs, releases and action files at a SHA rarely change between runs. - Handle rate limits (best practice): honor
retry-afterandx-ratelimit-reset, stop sending requests when the limit is reached, and report the checks we skipped as degraded instead of failing silently. Log the remaining quota at the end of a run (debug) so we can measure the gain. - Small ones:
per_page=100for environments (R4).
Implementation Hints
- Metadata client and per-ref probes:
github/github_metadata.go(resolveUncached,resolveTag,branchExists,commitResolves,releaseIsImmutable). - Comment tags:
github/github_workflows.go:356-362. - Raw/Contents fallback:
github/nested_actions.go(readWith),github/action_source.go(resolveMutableExec). - Scanned repo lanes:
github/github_branch_protection.go,github/github_workflows_remote.go(newGitHubRESTClient).
Why It's Valuable
Analyzes that hit the rate limit lose controls, or fail, on repositories with many actions. Fewer requests per analyze also leave room for users who run Plumber in several workflows with the same token.
Activity
Exypte commentedon Nov 18, 2026
I'm working on this one, a PR is on the way.
feat(github): send fewer GitHub requests per analyze
Totara-thib commentedon Nov 19, 2026
One case that #619 does not change: when the repository's token quota is already spent by other runs, the first API call fails with
HTTP 403: API rate limit exceededand the action ends red with exit 2 ("usage, configuration, or runtime error"), with no finding produced. The attestation check in the install step spends the same quota. Could an exhausted quota end neutral instead (a warning annotation and a skipped score push), keeping exit 2 for real configuration errors?fix(github): trust a raw 404 per repository and only at a commit SHA
feat(github): ask GitHub once which entrypoint guesses exist
test(github): run the entrypoint prefetch through the mutable-exec scan
test(cmd): check that analyze without --debug reads no rate limit, lo…
feat(github): send fewer GitHub requests per analyze
feat(github): send fewer GitHub requests and read GitHub through GraphQL
feat(github): send fewer GitHub requests and read GitHub through Grap…
chore(release): 0.7.24 [skip ci]