litmuschaos / litmusctl

Command-Line tool to manage Litmuschaos's agent plane
Apache License 2.0
24 stars 45 forks source link

Out of bound error in get projects command #183

Closed shivam-Purohit closed 9 months ago

shivam-Purohit commented 9 months ago

Description If there are no more projects to display litmusctl get projects throws out of bound error.

litmusctl get projects

PROJECT ID                  PROJECT NAME        CREATED AT
8adf62d5-64f8-4c66-ab53-63729db9dd9a        admin-project       55908-03-27 09:52:19 +0530 IST  

Press Enter to show the next page (or type 'q' to quit): 
panic: runtime error: slice bounds out of range [5:1]

goroutine 1 [running]:
github.com/litmuschaos/litmusctl/pkg/cmd/get.glob..func5(0xc000279d00?, {0x1813151?, 0x4?, 0x1812ff9?})
    /home/vboxuser/Desktop/lfx/litmusctl/pkg/cmd/get/projects.go:72 +0x50c
github.com/spf13/cobra.(*Command).execute(0x26646e0, {0x26a90a0, 0x0, 0x0})
    /home/vboxuser/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:860 +0x67b
github.com/spf13/cobra.(*Command).ExecuteC(0x265fbe0)
    /home/vboxuser/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:974 +0x38d
github.com/spf13/cobra.(*Command).Execute(...)
    /home/vboxuser/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:902
github.com/litmuschaos/litmusctl/pkg/cmd/root.Execute()
    /home/vboxuser/Desktop/lfx/litmusctl/pkg/cmd/root/root.go:62 +0x1a
main.main()
    /home/vboxuser/Desktop/lfx/litmusctl/main.go:33 +0x75

Possible solution It would be nice to add a little check if the start index goes out of bound and show a message that there exists no more projects.