Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab mr create crashes when assigning to unknown usernames #827

Closed
twouters opened this issue Apr 21, 2022 · 4 comments · Fixed by #828
Closed

lab mr create crashes when assigning to unknown usernames #827

twouters opened this issue Apr 21, 2022 · 4 comments · Fixed by #828

Comments

@twouters
Copy link

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
Copy link
Collaborator

prarit commented Apr 21, 2022

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
Copy link
Collaborator

prarit commented Apr 21, 2022

@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
Copy link
Contributor

@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
Copy link
Author

twouters commented Apr 21, 2022

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.

prarit added a commit to prarit/lab that referenced this issue Apr 21, 2022
'lab mr create -a <username>' panics if someone specifies a username that
doesn't exist:

[prarit@prarit kernel-test]$ ~/Other/github/lab/lab mr create -a prarit123456
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xc942b8]

goroutine 1 [running]:
github.com/zaquestion/lab/cmd.getUserIDs(0xc000242420, 0x1, 0x1, 0xc000034700, 0x0, 0x0)
	/home/prarit/Other/github/lab/cmd/util.go:662 +0x98
github.com/zaquestion/lab/cmd.runMRCreate(0x14a2940, 0xc0000fe540, 0x0, 0x2)
	/home/prarit/Other/github/lab/cmd/mr_create.go:347 +0x10e9
github.com/spf13/cobra.(*Command).execute(0x14a2940, 0xc0000fe520, 0x2, 0x2, 0x14a2940, 0xc0000fe520)
	/home/prarit/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:860 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x149c2c0, 0xc0000bc050, 0x5, 0x5)
	/home/prarit/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/prarit/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
github.com/zaquestion/lab/cmd.Execute(0xc000790500)
	/home/prarit/Other/github/lab/cmd/root.go:218 +0xf5
main.main()
	/home/prarit/Other/github/lab/main.go:27 +0x74

Fix the panic and output a warning that the username doesn't exist, and
continue to create the merge request.

Fixes zaquestion#827

Reported-by: GitHub User twouters
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
prarit added a commit that referenced this issue Apr 25, 2022
'lab mr create -a <username>' panics if someone specifies a username that
doesn't exist:

[prarit@prarit kernel-test]$ ~/Other/github/lab/lab mr create -a prarit123456
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xc942b8]

goroutine 1 [running]:
github.com/zaquestion/lab/cmd.getUserIDs(0xc000242420, 0x1, 0x1, 0xc000034700, 0x0, 0x0)
	/home/prarit/Other/github/lab/cmd/util.go:662 +0x98
github.com/zaquestion/lab/cmd.runMRCreate(0x14a2940, 0xc0000fe540, 0x0, 0x2)
	/home/prarit/Other/github/lab/cmd/mr_create.go:347 +0x10e9
github.com/spf13/cobra.(*Command).execute(0x14a2940, 0xc0000fe520, 0x2, 0x2, 0x14a2940, 0xc0000fe520)
	/home/prarit/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:860 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x149c2c0, 0xc0000bc050, 0x5, 0x5)
	/home/prarit/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/prarit/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
github.com/zaquestion/lab/cmd.Execute(0xc000790500)
	/home/prarit/Other/github/lab/cmd/root.go:218 +0xf5
main.main()
	/home/prarit/Other/github/lab/main.go:27 +0x74

Fix the panic and output a warning that the username doesn't exist, and
continue to create the merge request.

Fixes #827

Reported-by: GitHub User twouters
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants