Repository navigation
Open
Labels
bugSomething isn't workinggh-apirelating to the gh api commandpriority-3Affects a small number of users or is largely cosmetic
Description
Describe the bug
gh api crashes with a nil pointer dereference when a magic field (-F) with the literal value null is used on a nested array key, and a second field targets the same nested array element.
The crash happens while parsing the command line flags, before any HTTP request is made, so it is reproducible without network access.
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 #8762, so every release from v2.48.0 onward is affected, including the latest release v2.103.3.
Steps to reproduce the behavior
gh api user -F 'a[][b]=null' -F 'a[][b]=x'
Expected vs actual behavior
Expected: the request body should be built as {"a":[{"b":null},{"b":"x"}]} and the request sent.
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=0x0 pc=0xd999cb]
goroutine 1 [running]:
github.com/cli/cli/v2/pkg/cmd/api.addParamsSlice(0x9de41564390, {0x7ffcae24ee19, 0x1}, {0x7ffcae24ee1d, 0x1})
github.com/cli/cli/v2/pkg/cmd/api/fields.go:143 +0x14b
github.com/cli/cli/v2/pkg/cmd/api.parseFields.func1({0x7ffcae24ee19, 0x8}, 0x1)
github.com/cli/cli/v2/pkg/cmd/api/fields.go:75 +0x7b1
github.com/cli/cli/v2/pkg/cmd/api.parseFields(0x9de4137c140)
github.com/cli/cli/v2/pkg/cmd/api/fields.go:115 +0xee
github.com/cli/cli/v2/pkg/cmd/api.apiRun(0x9de4137c140)
github.com/cli/cli/v2/pkg/cmd/api/api.go:314 +0x33
github.com/cli/cli/v2/pkg/cmd/api.NewCmdApi.func2(0x9de41364008, {0x9de413e0a50?, 0x0?, 0x0?})
github.com/cli/cli/v2/pkg/cmd/api/api.go:290 +0x2c9
github.com/cli/cli/v2/pkg/cmdutil.RecordTelemetry.func2(0x9de41364008, {0x9de41364008, 0x1?, 0x5?})
github.com/cli/cli/v2/pkg/cmdutil/telemetry.go:40 +0x32
github.com/spf13/cobra.(*Command).execute(0x9de41364008, {0x9de413e0a00, 0x5, 0x5})
github.com/spf13/[email protected]/command.go:1015 +0xb3
github.com/spf13/cobra.(*Command).ExecuteC(0x9de41047b08)
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
Metadata
Metadata
Assignees
Labels
bugSomething isn't workinggh-apirelating to the gh api commandpriority-3Affects a small number of users or is largely cosmetic
Activity
cli-triage commentedon Nov 7, 2026
Reproducible on 2.103.3.
Using test data, the command crashes while parsing fields, before any request is sent:
Exit status:
2.The latest release and current source build also crash with the same stack location. The
nullvalue becomes nil, and the next nested field causes the parser to inspect its type without first checking for nil. This looks ready for a focused parser fix and a regression test covering nested array fields.Supporting reports
Duplicate analysis
Label reasoning
Reproduction log
Investigation notes
Generated by issue triage.
fix: handle nil values in nested array field parsing
fix: handle nil values in nested array field parsing