gh run list fails with 404 on specific GitHub repository actions/runs endpoint
gh run list -R <owner>/<repo> fails with HTTP 404 on a repo where auth is correct and other endpoints work:
$ gh run list -R acme-org/webapp -b master -L 12
failed to get runs: HTTP 404: Not Found (https://api.github.com/repos/acme-org/webapp/actions/runs?per_page=12&exclude_pull_requests=true&branch=master)The 404 persists without -b, and via gh api directly. But these all succeed against the same repo in the same shell:
gh repo view --json nameWithOwner->{"nameWithOwner":"acme-org/webapp"}gh api repos/OWNER/REPO/actions/workflows->total_count: 7, full listgh api "repos/OWNER/REPO/actions/workflows/<id>/runs?branch=master&per_page=40"->total_count: 738, full run list
gh auth status shows the correct account as Active account: true with scopes gist, read:org, repo.
Why this wastes time: with multiple GitHub accounts, a 404 from gh is the well-known tell for "wrong account is active" — it reads as a missing repo, not an auth problem, and the documented fix is gh auth switch --user <account>. That diagnosis is wrong here, and it sends you into account switching, scope checking, and token re-auth. The discriminator is that the wrong-account 404 also breaks gh repo view, whereas this failure is scoped to the repo-wide actions/runs collection endpoint only.
Observed 2026-08-17.
Diagnose with a 3-step ladder before touching auth, then use the per-workflow endpoint as the workaround.
Ladder — each step rules out a different cause:
gh repo view -R O/R --json nameWithOwner— fails too? Then it IS the wrong-account/permissions 404;gh auth switch --user <acct>. Succeeds? Auth is fine, stop looking at it.gh api repos/O/R/actions/workflows— fails? Actions is disabled on the repo. Succeeds? Actions is enabled and readable.gh api "repos/O/R/actions/workflows/<id>/runs"— succeeds? The fault is isolated to the repo-wideactions/runscollection endpoint.
Workaround — enumerate workflows, then query runs per workflow:
gh api repos/O/R/actions/workflows --jq '.workflows[] | "\(.id)\t\(.name)"' |
while IFS=$'\t' read -r id name; do
latest=$(gh api "repos/O/R/actions/workflows/$id/runs?branch=master&per_page=1" \
--jq '.workflow_runs[0] | "\(.conclusion)\t\(.head_sha[0:9])\t\(.created_at)"')
printf '%s\t%s\n' "$name" "${latest:-no master runs}"
doneWorth the detour: the per-workflow view surfaces something the repo-wide call structurally cannot — workflows with zero runs on the default branch. In this repo 5 of 7 were pull_request-only, so a build break landing on the default branch produced no red check anywhere. A repo-wide "latest run per workflow name" query cannot show you a workflow that never ran; per-workflow enumeration reports it as an explicit empty set. Report those as "no master runs (PR-only)" rather than leaving the row blank, or the absence reads as a pass.