Repository navigation
Open
Labels
bugSomething isn't workinggh-aliasrelated to the gh alias commandpriority-3Affects a small number of users or is largely cosmetic
Description
Describe the bug
gh crashes with a stack overflow when an alias expands to itself.
An alias whose expansion resolves back to the same alias is accepted without complaint, and running it re-enters the alias forever until the Go runtime aborts the process.
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
-
Create an alias that expands to itself:
gh alias set 'issue mine' 'issue mine'This is accepted and exits 0.
-
Run the alias:
gh issue mine -
See error
The same happens when the alias arrives through gh alias import, which is how a shared alias file would carry it:
$ cat aliases.yml
pr mine: pr mine
$ gh alias import aliases.yml
$ gh pr mine
Expected vs actual behavior
Expected: gh should either refuse to create an alias that expands to itself, or report an error when the alias is run.
Actual: gh recurses until the runtime aborts the process with fatal error: stack overflow, after about 30 seconds and roughly 1 GB of goroutine stack.
Logs
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0x184c88b003a8 stack=[0x184c88b00000, 0x184ca8b00000]
fatal error: stack overflow
runtime stack:
runtime/panic.go:1243 +0x48
runtime/stack.go:1207 +0x5dd
runtime/asm_amd64.s:650 +0x7b
goroutine 1 gp=0x184c62f4a1e0 m=23 mp=0x184c74808008 [running]:
regexp/syntax.(*compiler).rune(...)
regexp/syntax/compile.go:272 +0x2d3
...
regexp.MustCompile({0x14effea, 0x4})
regexp/regexp.go:310 +0x2c
github.com/cli/cli/v2/pkg/cmd/root.expandAlias({0x184c6349faa0?, 0x184c633e2ab0?}, {0x2b1f980?, 0x0, 0x14f3f6a?})
github.com/cli/cli/v2/pkg/cmd/root/alias.go:91 +0x28a
github.com/cli/cli/v2/pkg/cmd/root.NewCmdAlias.func1(0x184c6372d808, {0x2b1f980?, 0x4?, 0x14efff2?})
github.com/cli/cli/v2/pkg/cmd/root/alias.go:58 +0x35
github.com/spf13/cobra.(*Command).execute(0x184c6372d808, {0x2b1f980, 0x0, 0x0})
github.com/spf13/[email protected]/command.go:1015 +0xb3c
github.com/spf13/cobra.(*Command).ExecuteC(0x184c6372d808)
github.com/spf13/[email protected]/command.go:1148 +0x450
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:1071
github.com/cli/cli/v2/pkg/cmd/root.NewCmdAlias.func1(...)
github.com/cli/cli/v2/pkg/cmd/root/alias.go:64 +0xb2
github.com/spf13/cobra.(*Command).execute(...)
github.com/spf13/[email protected]/command.go:1015 +0xb3c
github.com/spf13/cobra.(*Command).ExecuteC(...)
github.com/spf13/[email protected]/command.go:1148 +0x450
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:1071
github.com/cli/cli/v2/pkg/cmd/root.NewCmdAlias.func1(...)
github.com/cli/cli/v2/pkg/cmd/root/alias.go:64 +0xb2
... and the same two frames repeat until the stack limit is hit
exit status 2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workinggh-aliasrelated to the gh alias commandpriority-3Affects a small number of users or is largely cosmetic
Activity
cli-triage commentedon Nov 7, 2026
Reproducible on source-736c68f.
With a self-referential alias in a clean test configuration:
Exit status:
2.The command repeatedly re-enters alias execution until the Go runtime aborts. The same command also failed to finish within five seconds on released 2.103.3, with no output or API requests, matching the same recursion path. Removing or correcting the alias avoids the crash, but
ghshould detect the cycle and return a normal error.Supporting reports
Duplicate analysis
Label reasoning
Reproduction log
Investigation notes
Generated by issue triage.
ArianPashae commentedon Nov 19, 2026