Skip to content

gh pr view --json crashes when trying to fetch closed field #3539

@cristiand391

Description

@cristiand391

Describe the bug

gh crashes when trying to fetch the closed data field with --json, affected commands:

  • gh pr view
  • gh pr list
  • gh pr status
gh --version

gh version 1.9.2 (2021-04-20)
https://github.com/cli/cli/releases/tag/v1.9.2

Steps to reproduce the behavior

  1. Type gh pr <view | list | status> --json closed
  2. View the output:

Expected vs actual behavior

It should be able to fetch the closed field but it crashes when trying to do so.

Logs

gh pr view 3524 --json closed -R cli/cli

panic: reflect: call of reflect.Value.Interface on zero Value

goroutine 1 [running]:
reflect.valueInterface(0x0, 0x0, 0x0, 0xc000666601, 0x6, 0x0)
        /opt/hostedtoolcache/go/1.15.11/x64/src/reflect/value.go:1021 +0x1ad
reflect.Value.Interface(...)
        /opt/hostedtoolcache/go/1.15.11/x64/src/reflect/value.go:1016
github.com/cli/cli/api.(*PullRequest).ExportData(0xc000692840, 0xc000648b40, 0x1, 0x1, 0xe61a01)
        /home/runner/work/cli/cli/api/export_pr.go:80 +0x215
github.com/cli/cli/pkg/cmd/pr/view.viewRun(0xc0004030a0, 0x0, 0x0)
        /home/runner/work/cli/cli/pkg/cmd/pr/view/view.go:120 +0x52a
github.com/cli/cli/pkg/cmd/pr/view.NewCmdView.func1(0xc000518dc0, 0xc00063c230, 0x1, 0x5, 0x0, 0x0)
        /home/runner/work/cli/cli/pkg/cmd/pr/view/view.go:82 +0x10b
github.com/spf13/cobra.(*Command).execute(0xc000518dc0, 0xc00063c1e0, 0x5, 0x5, 0xc000518dc0, 0xc00063c1e0)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:850 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0xc00037b8c0, 0xc000648a30, 0x1, 0x7)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
main.mainRun(0xc0000300b8)
        /home/runner/work/cli/cli/cmd/gh/main.go:167 +0xa28
main.main()
        /home/runner/work/cli/cli/cmd/gh/main.go:47 +0x25

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority-3Affects 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