Skip to content

panic: reflect: call of reflect.Value.Interface on zero Value when gh pr view --json stateReason #9160

@Frederick888

Description

@Frederick888

Describe the bug

$ gh --version
gh version 2.50.0 (2024-05-29)
https://github.com/cli/cli/releases/tag/v2.50.0
$ gh pr view --json stateReason
panic: reflect: call of reflect.Value.Interface on zero Value

goroutine 1 [running]:
reflect.valueInterface({0x0?, 0x0?, 0x0?}, 0x0?)
        reflect/value.go:1501 +0xfb
reflect.Value.Interface(...)
        reflect/value.go:1496
github.com/cli/cli/v2/api.(*PullRequest).ExportData(0xc00066d188, {0xc000958990, 0x1, 0xc0008bf438?})
        github.com/cli/cli/v2/api/export_pr.go:144 +0x968
github.com/cli/cli/v2/pkg/cmdutil.(*jsonExporter).exportData(0xc0003a4480, {0x10bdd3cc0?, 0xc00066d188?, 0xc00079cfc0?})
        github.com/cli/cli/v2/pkg/cmdutil/json_flags.go:259 +0x52a
github.com/cli/cli/v2/pkg/cmdutil.(*jsonExporter).exportData(0xc0003a4480, {0x10bd23e60?, 0xc00066d188?, 0x109915c45?})
        github.com/cli/cli/v2/pkg/cmdutil/json_flags.go:239 +0x3ac
github.com/cli/cli/v2/pkg/cmdutil.(*jsonExporter).Write(0xc0003a4480, 0xc000429e40, {0x10bd23e60, 0xc00066d188})
        github.com/cli/cli/v2/pkg/cmdutil/json_flags.go:205 +0x11c
github.com/cli/cli/v2/pkg/cmd/pr/view.viewRun(0xc000644600)
        github.com/cli/cli/v2/pkg/cmd/pr/view/view.go:121 +0x3f5
github.com/cli/cli/v2/pkg/cmd/pr/view.NewCmdView.func1(0xc00069c008, {0xc00049ebc0, 0x0, 0x10a8a9242?})
        github.com/cli/cli/v2/pkg/cmd/pr/view/view.go:69 +0x349
github.com/spf13/cobra.(*Command).execute(0xc00069c008, {0xc00049eba0, 0x2, 0x2})
        github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000459808)
        github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        github.com/spf13/cobra@v1.8.0/command.go:1048
main.mainRun()
        github.com/cli/cli/v2/cmd/gh/main.go:119 +0x53b
main.main()
        github.com/cli/cli/v2/cmd/gh/main.go:46 +0x13

Steps to reproduce the behavior

  1. Check out or submit a PR
  2. gh pr view --json stateReason
  3. See error

Expected vs actual behavior

Expected: It prints out a JSON with stateReason.

Actual: gh crashes.

Logs

(See above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-prrelating to the gh pr commandhelp wantedContributions welcomep3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions