`glab pipeline ci view` command crashes on branch with child pipelines

Created by: pedropombeiro

Description

The following command crashes:

glab pipeline ci view -b some-branch
2020/09/18 10:51:36 runtime error: invalid memory address or nil pointer dereference
goroutine 1 [running]:
runtime/debug.Stack(0xc0001a02a0, 0x18b98a0, 0x2134e60)
	/opt/hostedtoolcache/go/1.14.7/x64/src/runtime/debug/stack.go:24 +0x9d
glab/commands.recoverPanic(0xc0001a02a0)
	/home/runner/work/glab/glab/commands/pipeline_ci_view.go:519 +0x65
panic(0x18b98a0, 0x2134e60)
	/opt/hostedtoolcache/go/1.14.7/x64/src/runtime/panic.go:969 +0x166
glab/commands.glob..func26(0x2143c20, 0xc00031e5a0, 0x0, 0x2)
	/home/runner/work/glab/glab/commands/pipeline_ci_view.go:82 +0x420
github.com/spf13/cobra.(*Command).execute(0x2143c20, 0xc00031e520, 0x2, 0x2, 0x2143c20, 0xc00031e520)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0x2146380, 0xc00001e1f0, 0x5, 0x5)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
main.main()
	/home/runner/work/glab/glab/cmd/glab/main.go:59 +0x239

Expected Behavior

I should be able to see the pipeline, as for branches which don't contain child pipelines.

Actual Behavior

The app crashes because this particular branch contains a dynamically generated child pipeline.

Possible Fix

Steps to Reproduce

  1. Create a child pipeline on a .gitlab-ci.yml file
  2. Run the pipeline
  3. Run glab pipeline ci view -b on the branch containing that pipeline
  4. Watch the app crash

Context

Your Environment

  • Version used: 1.10
  • Operating System and version: MacOS 10.15.6