Description
Describe the bug
gh pr view crashes with a panic when a pull request has more than 100 status checks and the pull request stops resolving between the two API requests that gh makes to collect them.
The check contexts of a pull request are paginated, so gh makes a second request for the remaining contexts. The second response is read without checking that the pull request it refers to is still there, which produces either a nil pointer dereference or an index out of range error.
Affected version
$ gh version
gh version 2.103.3-71-g736c68f67 (2026-11-07)
https://github.com/cli/cli/releases/latest
This is a build of trunk.
Steps to reproduce the behavior
-
Open a pull request that has more than 100 status checks, for example one that runs a large CI matrix.
-
While
gh pr viewis running, make the pull request stop resolving. For example, delete the head branch or the pull request itself. -
Run:
gh pr view <number> -
View the output
-
See error
The crash also happens if the pull request still resolves but the list of commits comes back empty, which gives an index out of range error instead of a nil pointer dereference.
gh pr view --json statusCheckRollup reaches the same code.
Expected vs actual behavior
Expected: gh should report that the pull request's checks could not be read, the way it reports other failures while collecting a pull request's data.
Actual: gh panics and exits with status 2.
Logs
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x228 pc=0xd78d54]
goroutine 72 [running]:
github.com/cli/cli/v2/pkg/cmd/pr/shared.preloadPrChecks(0xed5071ec210, {0x29538a0, 0xed5071ec180}, 0xed506c49008)
github.com/cli/cli/v2/pkg/cmd/pr/shared/finder.go:600 +0x2b4
github.com/cli/cli/v2/pkg/cmd/pr/shared.(*finder).Find.func4()
github.com/cli/cli/v2/pkg/cmd/pr/shared/finder.go:284 +0x27
golang.org/x/sync/errgroup.(*Group).Go.func1()
golang.org/x/sync@v0.24.0/errgroup/errgroup.go:93 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
golang.org/x/sync@v0.24.0/errgroup/errgroup.go:78 +0xa5
...
exit status 2
With an empty commit list instead of a missing pull request, the panic is:
panic: runtime error: index out of range [0] with length 0
goroutine 72 [running]:
github.com/cli/cli/v2/pkg/cmd/pr/shared.preloadPrChecks(0xed5071ec210, {0x29538a0, 0xed5071ec180}, 0xed506c49008)
github.com/cli/cli/v2/pkg/cmd/pr/shared/finder.go:600 +0x426
github.com/cli/cli/v2/pkg/cmd/pr/shared.(*finder).Find.func4()
github.com/cli/cli/v2/pkg/cmd/pr/shared/finder.go:284 +0x27
...
exit status 2
Activity
cli-triage commentedon Nov 7, 2026
Reproducible on 2.103.3.
Using test data where the first response reports another page of status checks and the next response no longer contains the pull request:
Exit status:
2.The latest release and source snapshot at
736c68f674113337685e3eb1f908602a03b8f99bbehave the same way. The paginated response is read without first checking that the pull request node and latest commit are present.ghshould return a normal error instead of panicking.Supporting reports
Duplicate analysis
Label reasoning
Reproduction log
Investigation notes
Generated by issue triage.