Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Panic in gh pr view --comments due to nil pointer dereference in project items #12325

@chrishenzie

Description

@chrishenzie

Describe the bug

When running gh pr view <number> --comments, the CLI panics with a runtime error: invalid memory address or nil pointer dereference.

This occurs in api/queries_projects_v2.go when processing projectItems. It appears the GraphQL API is returning null nodes in the projectItems connection, which the client does not check before dereferencing.

I observed this even when using a personal access token with full read-only access to all scopes, so I don't think this is a permission issue.

Affected version

$ gh version
gh version 2.83.1-68-g51dfeeaa7 (2025-12-16)
https://github.com/cli/cli/releases/latest

Steps to reproduce the behavior

$ gh pr view 5475 --repo kubernetes/enhancements
⡿panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x84fbaa]

goroutine 102 [running]:
github.com/cli/cli/v2/api.ProjectsV2ItemsForPullRequest(0xc00006ff60, {0x25b5320, 0xc0002490b0}, 0xc00085d008)
        github.com/cli/cli/v2/api/queries_projects_v2.go:179 +0x3aa
github.com/cli/cli/v2/pkg/cmd/pr/shared.(*finder).Find.func5()
        github.com/cli/cli/v2/pkg/cmd/pr/shared/finder.go:295 +0x32
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/[email protected]/errgroup/errgroup.go:93 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
        golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x95

Expected vs actual behavior

The gh CLI returns PR details.

See above for the actual behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-prrelating to the gh pr commandneeds-triageneeds to be reviewedp2Affects more than a few users but doesn't prevent core functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions