zaquestion / lab

Lab wraps Git or Hub, making it simple to clone, fork, and interact with repositories on GitLab
https://zaquestion.github.io/lab
Creative Commons Zero v1.0 Universal
1.11k stars 102 forks source link

lab mr create crashes when assigning to unknown usernames #827

Closed twouters closed 2 years ago

twouters commented 2 years ago

lab mr create -a <username> throws a segmentation fault when a username doesn't exist on a gitlab instance (because of typo's or just forgetting the actual username or whatever).
This is especially annoying because I usually run into this after writing lengthy MR descriptions and have to start typing it all over again.

Could it be changed to first check if users actually exist before initiating the editor to edit MERGEREQ_EDITMSG, or catch these (or similar) errors and save/cache the submitted MR description somewhere so that it can be retried?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x557e47dcb4f5]

goroutine 1 [running]:
github.com/zaquestion/lab/cmd.getUserIDs(...)
    github.com/zaquestion/lab/cmd/util.go:648
github.com/zaquestion/lab/cmd.runMRCreate(0x557e48835560?, {0xc0003d45c0, 0x2, 0x4?})
    github.com/zaquestion/lab/cmd/mr_create.go:326 +0x1cd5
github.com/spf13/cobra.(*Command).execute(0x557e48835560, {0xc0003d4580, 0x4, 0x4})
    github.com/spf13/cobra@v1.2.1/command.go:860 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0x557e488357e0)
    github.com/spf13/cobra@v1.2.1/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
    github.com/spf13/cobra@v1.2.1/command.go:902
github.com/zaquestion/lab/cmd.Execute(0x40?)
    github.com/zaquestion/lab/cmd/root.go:218 +0x1df
main.main()
    github.com/zaquestion/lab/main.go:27 +0x1c5
prarit commented 2 years ago

Thanks for the well-written bug report and I can understand your pain :)

ISTR we do save buffer output on errors with 'lab edit'. I think this should be possible to do with 'lab create'.

I'll look into this.

prarit commented 2 years ago

@twouters would be it be better to create the MR, and then write an error message to the console indicating that the user could not be found?

fmuellner commented 2 years ago

@twouters would be it be better to create the MR, and then write an error message to the console indicating that the user could not be found?

Maybe also mention that the assignee can be changed with lab mr edit <id> --assign <user>? (filling in the MR ID, and maybe the (wrong) username)

twouters commented 2 years ago

I'm fine with that, if the buffer output is saved and can be restored I just figured you mean to actually create the MR in gitlab, that sounds even better.