`gh pr checks` exits 1 for "no checks reported", the same code as failed checks
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 50/100
Direzione di ricerca
Start in pkg/cmd/pr/checks/checks.go, where populateStatusChecks returns a plain error when the rollup has no nodes, then compare with how internal/ghcmd/cmd.go maps cmdutil.NewNoResultsError to exit 0. Choose between the two options in the issue, which needs a maintainer decision, and update the 'Additional exit codes' help text. Done means a PR with no checks exits with a code distinct from failed checks, with the --watch loop still waiting, and a test covering it.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
gh pr checks <pr> on a pull request whose head commit has no check runs or statuses prints no checks reported on the '<branch>' branch and exits 1. Failed checks also exit 1, so a script or an AI coding agent that runs gh pr checks just to look at CI state cannot tell "nothing ran" from "something failed" without parsing the message.
This was asked for in #9390, but #9452 closed that issue by documenting only exit code 8 (pending). The "no checks" case still exits 1 in gh 2.102.0, and gh pr checks --help doesn't document it. #9682 covers only the --required variant ("no required checks reported").
Steps to reproduce the behavior
On any pull request without checks, for example a merged PR in a repository whose Actions did not run for it:
$ gh --version
gh version 2.102.0 (2026-09-30)
$ gh pr checks 414 --repo G-Ivan-A/mango_ba_prompts; echo "exit=$?"
no checks reported on the 'issue-413-e424ca2a7c62' branch
exit=1
$ gh pr view 414 --repo G-Ivan-A/mango_ba_prompts --json statusCheckRollup --jq '.statusCheckRollup | length'; echo "exit=$?"
0
exit=0
A PR with a failing check gives the same exit=1.
Expected vs actual behavior
- Expected: "no checks" can be told apart from "checks failed" by exit code, and the code is documented under "Additional exit codes" in
gh pr checks --help. - Actual: both exit 1, and only the message text tells them apart.
Impact
In link-assistant/hive-mind#3922, an AI agent ended a successful session with …; gh pr checks 414 --repo … to look at the PR state. Because the shell exited 1, the orchestrator treated the last tool call as a failed verification and marked the whole session as failed. electron/electron#49630 hit the same problem in CI scripts.
Workarounds
gh pr view <pr> --json statusCheckRollup --jq '.statusCheckRollup | length'returns0with exit 0 when there are no checks.- Match the exact text
no checks reported on the '<branch>' branchon exit 1. This is what hive-mind now does.
Suggested fix
In pkg/cmd/pr/checks/checks.go, populateStatusChecks returns a plain error:
if len(statusCheckRollup.Nodes) == 0 {
return nil, checkCounts{}, fmt.Errorf("no checks reported on the '%s' branch", pr.HeadRefName)
}
Either of these would fix it:
- Return
cmdutil.NewNoResultsError(fmt.Sprintf("no checks reported on the '%s' branch", pr.HeadRefName)).internal/ghcmd/cmd.goalready mapsNoResultsErrorto exit 0 and prints the message on a TTY, asgh label list,gh workflow listand others do. The--watchloop would need to keep treating "no checks yet" as "keep waiting" (see #7401). - If changing exit 1 → 0 is too breaking for scripts that rely on it, return a distinct, documented code for "no checks". This mirrors exit 8 for pending, and the same code could serve the
--requiredcase in #9682.
In both cases, add the code to the "Additional exit codes" help text.
- Lingua principale
- Go
- Stelle
- 46.8k
- Fork
- 9.2k
- Merge medio
- 1g 14h
- PR unite (30g)
- 60
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cli/cli
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
docs: cover gh api mutation pitfalls in the gh skillForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaenhancement
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
`gh skill update` help incorrectly promises to preserve locally added filesForse già presa @rajpreetcodes l’ha presa 19 giorni fa. Apertabug gh-skill priority-3
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
cli/cli#14647 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
`gh` skill description does not tell agents when to use it, so it is skipped for tasks it coversForse già presa @littfed l’ha presa 24 giorni fa. Apertaenhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
cli/cli#14621 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
[mesheryctl] design delete fails when passing file or URL as positional argumentForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertacomponent/mesheryctl kind/bug language/go
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
meshery/meshery#22772 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
backend security size:S
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
limitlessprojects/Go-Hybrid#3342 ·
I maintainer di solito rispondono entro 1 giorno
-
status/ready type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
buildpacks/pack#2733 ·
I maintainer di solito rispondono entro 1 giorno