From 07ee387f25220b0e97455f6266e89a68bc409cfb Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Mon, 2 Oct 2023 00:03:24 -0700 Subject: [PATCH] pkg/cmd/root: fix startup panic (#8105) --- pkg/cmd/root/root.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/root/root.go b/pkg/cmd/root/root.go index 353b9836a..db591c27b 100644 --- a/pkg/cmd/root/root.go +++ b/pkg/cmd/root/root.go @@ -72,7 +72,8 @@ func NewCmdRoot(f *cmdutil.Factory, version, buildDate string) (*cobra.Command, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { // require that the user is authenticated before running most commands if cmdutil.IsAuthCheckEnabled(cmd) && !cmdutil.CheckAuth(cfg) { - if cmd.Parent().Use == "codespace" { + parent := cmd.Parent() + if parent != nil && parent.Use == "codespace" { fmt.Fprintln(io.ErrOut, "To get started with GitHub CLI, please run: gh auth login -s codespace") } else { fmt.Fprint(io.ErrOut, authHelp())