Repository navigation
Description
Describe the bug
gh crashes with an index out of range panic when the configured pager command tokenizes to zero words, for example a comment-only or whitespace-only string.
The pager can be set through GH_PAGER, PAGER, or gh config set pager, and the panic affects every command that pages its output, such as gh pr list, gh issue list, gh repo list, gh release list, gh run list, gh secret list, and gh search ....
The crash requires stdout to be a terminal, which is the case where a pager is actually used.
I have a fix to PR if the issue can be labelled appropriately 🙂
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. The offending code has not changed since it was introduced in #1630, so every release since v1.0.0 is affected, including the latest release v2.103.3.
Steps to reproduce the behavior
-
Set a pager command that contains no executable name:
gh config set pager '#' -
Run a command that pages its output, in an interactive terminal:
gh help reference -
See error
Setting GH_PAGER='#' or PAGER=' ' instead of the config file has the same effect.
Expected vs actual behavior
Expected: a pager command that names no executable should be treated the same way as the existing "" and "cat" special cases, namely as "no pager".
Actual: gh panics and exits with status 2.
Logs
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
github.com/cli/cli/v2/pkg/iostreams.(*IOStreams).StartPager(0x35ff5b5bc300)
github.com/cli/cli/v2/pkg/iostreams/iostreams.go:240 +0x7aa
github.com/cli/cli/v2/pkg/cmd/root.longPager.func1(0x35ff5b801208, {0x2b08940?, 0x35ff5bb1b200?, 0x35ff5ba1f7e0?})
github.com/cli/cli/v2/pkg/cmd/root/help_reference.go:37 +0x113
github.com/spf13/cobra.(*Command).Help(0x35ff5b801208)
github.com/spf13/[email protected]/command.go:521 +0x33
github.com/spf13/cobra.(*Command).InitDefaultHelpCmd.func2(0x35ff5b819208, {0x35ff5b0add30, 0x1, 0x1})
github.com/spf13/[email protected]/command.go:1306 +0xbd
github.com/spf13/cobra.(*Command).execute(0x35ff5b819208, {0x35ff5b819208, 0x60, 0x60})
github.com/spf13/[email protected]/command.go:1019 +0xb23
github.com/spf13/cobra.(*Command).ExecuteC(0x35ff5b5a4908)
github.com/spf13/[email protected]/command.go:1148 +0x450
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
github.com/spf13/[email protected]/command.go:1080
github.com/cli/cli/v2/internal/ghcmd.Main()
github.com/cli/cli/v2/internal/ghcmd/cmd.go:187 +0x1065
main.main()
github.com/cli/cli/v2/cmd/gh/main.go:10 +0x13
exit status 2
Activity
cli-triage commentedon Nov 7, 2026
Unable to test: terminal command execution was blocked.
The planned check was:
$ GH_PAGER='#' gh help referenceExit status: not available.
The released 2.103.3 source still parses the non-empty pager value and then reads the first parsed argument without checking whether parsing returned any arguments. That matches the reported index-out-of-range path for comment-only or whitespace-only values. Using
cat, a valid pager command, or unsetting the pager avoids the path. A terminal reproduction is still needed before treating this as fully reproduced.Supporting reports
Duplicate analysis
Label reasoning
Reproduction log
Investigation notes
Generated by issue triage.
ArianPashae commentedon Nov 18, 2026