cli/cli · error
no commit found on the pull request
Error message
no commit found on the pull request
What it means
Thrown by the checks-rolling query in gh pr checks when the PR's StatusCheckRollup node list is empty - meaning the head commit has no check contexts to report. Most commonly this happens for PRs whose head commit has not been pushed or has no CI configured, or empty PRs.
Source
Thrown at pkg/cmd/pr/checks/checks.go:287
}
}
}`, api.RequiredStatusCheckRollupGraphQL("$id", "$endCursor", includeEvent))
variables := map[string]interface{}{
"id": pr.ID,
}
statusCheckRollup := api.CheckContexts{}
for {
var resp response
err := apiClient.GraphQL(repo.RepoHost(), query, variables, &resp)
if err != nil {
return nil, checkCounts{}, err
}
if len(resp.Node.StatusCheckRollup.Nodes) == 0 {
return nil, checkCounts{}, errors.New("no commit found on the pull request")
}
result := resp.Node.StatusCheckRollup.Nodes[0].Commit.StatusCheckRollup.Contexts
statusCheckRollup.Nodes = append(
statusCheckRollup.Nodes,
result.Nodes...,
)
if !result.PageInfo.HasNextPage {
break
}
variables["endCursor"] = result.PageInfo.EndCursor
}
if len(statusCheckRollup.Nodes) == 0 {
return nil, checkCounts{}, fmt.Errorf("no checks reported on the '%s' branch", pr.HeadRefName)
}
View on GitHub (pinned to 0eeec0b92e)
Solutions
- Confirm the PR has a head commit and diff: `gh pr view <n> --json commits,state`
- If the repo has no checks configured, skip polling; gate on workflow existence (`gh workflow list`)
- Wait for CI to start before polling, or use `gh pr checks <n> --watch` which tolerates the startup window once contexts exist
Example fix
# before gh pr checks 7 # PR just opened, CI not started, no checks ever configured # after gh pr checks 7 --json 2>/dev/null || echo "no checks; repo has no CI configured"
Defensive patterns
Strategy: validation
Validate before calling
commits=$(gh pr view $N --json commits --jq 'length')
[ "$commits" -gt 0 ] || { echo "PR has no commits; nothing to check" >&2; exit 0; }
gh pr checks $N Try / catch
Treat 'no commit found on the pull request' as a soft-empty in scripts: if grep -q matches, exit 0 (no CI) rather than failing the pipeline.
Prevention
- Confirm the PR has a head commit before polling checks
- Gate check-polling on at least one configured workflow (gh workflow list)
- Add a startup delay or event trigger (push webhook) instead of polling instantly after pr create
When it happens
Trigger: `gh pr checks <n>` where the pull request has zero commits (opened from a branch with no diff/no pushed head), or where the rollup query returns an empty node list for the head SHA; commonly right after opening a PR before CI triggers with no required checks configured.
Common situations: Polling `gh pr checks --watch` in CI immediately after PR creation; repos with no workflows/checks at all; PRs from deleted head branches.
Related errors
- pull request title must not be blank
- this type of review cannot be blank
- no comments found for current user
- empty reference
- --editor or enabled prefer_editor_prompt configuration are n
AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15).
Data as JSON: /api/errors/f3ac035d5cd0b070.
Report an issue: GitHub.