semaphoreci / cli

Semaphore 2.0 Command Line Interface
Apache License 2.0
25 stars 13 forks source link

Panic triggered when providing pipeline ID to workflows #177

Open twcurrie opened 3 years ago

twcurrie commented 3 years ago

Accidentally put a pipeline-id into the workflow command and triggered a panic. Probably should fail more gracefully.

sem get workflow <pipeline-id>
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/semaphoreci/cli/cmd/workflows.prettyPrintPipelineList(0xc0003e1200, 0x2, 0x600)
    /home/semaphore/cli/cmd/workflows/describe.go:31 +0x4e7
github.com/semaphoreci/cli/cmd/workflows.Describe(0xc0003699b0, 0x24, 0x7ffeefbffaf9, 0x24)
    /home/semaphore/cli/cmd/workflows/describe.go:20 +0xe9
github.com/semaphoreci/cli/cmd.glob..func23(0x183a0a0, 0xc00004f540, 0x1, 0x1)
    /home/semaphore/cli/cmd/get.go:251 +0x7b
github.com/spf13/cobra.(*Command).execute(0x183a0a0, 0xc00004f520, 0x1, 0x1, 0x183a0a0, 0xc00004f520)
    /home/semaphore/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x2cc
github.com/spf13/cobra.(*Command).ExecuteC(0x1837380, 0x0, 0x0, 0xc000101ee0)
    /home/semaphore/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x2fd
github.com/spf13/cobra.(*Command).Execute(0x1837380, 0x6b, 0xa0)
    /home/semaphore/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800 +0x2b
github.com/semaphoreci/cli/cmd.Execute()
    /home/semaphore/cli/cmd/root.go:37 +0x2d
main.main()
    /home/semaphore/cli/main.go:27 +0x216
raphaeljlps commented 2 years ago

@twcurrie This one is easy to fix, the problem is adding tests to cover the function.