Segmentation violation on snitch purge
ankokovin opened this issue · 3 comments
ankokovin commented
snitch purge
...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x6ba4b9]
goroutine 1 [running]:
main.GithubCredentials.getIssue(0xc00001c0d6, 0x28, 0xc000018fe0, 0x18, 0xc000138640, 0x6, 0xc00013864c, 0x36, 0x75d14e, 0x4, ...)
/home/aleksei/go/src/github.com/tsoding/snitch/github.go:39 +0x29
main.Todo.RetrieveStatus(0xc000138640, 0x6, 0xc00013864c, 0x36, 0x75d14e, 0x4, 0x0, 0xc0000fc0c0, 0x5e, 0x1f, ...)
/home/aleksei/go/src/github.com/tsoding/snitch/todo.go:160 +0x90
main.purgeSubcommand(0xc00000e4a0, 0xc00004ad10, 0x1, 0x1, 0x75cee1, 0x3, 0x7d5960, 0xc00004ad30, 0xc000018fe0, 0x18, ...)
/home/aleksei/go/src/github.com/tsoding/snitch/main.go:123 +0x202
main.main()
/home/aleksei/go/src/github.com/tsoding/snitch/main.go:424 +0x4be
snitch list
and snitch report
works fine
rexim commented
@ankokovin thanks for reporting that! I've been experiencing it from time to time but could not find time to properly report it. I'll look into when I get a chance.
I also remember @aod saying they know something about this problem. 🤔
aod commented
I think this bug happens when snitch tries to purge a todo without an ID 😅.
The following patch should suffice:
diff --git a/main.go b/main.go
index 4ecd8e1..4fe376c 100644
--- a/main.go
+++ b/main.go
@@ -119,6 +119,9 @@ func purgeSubcommand(project Project, creds IssueAPI, repo string) error {
cancel()
return v.err
}
+ if v.todo.ID == nil {
+ continue
+ }
status, err := v.todo.RetrieveStatus(creds, repo)
if err != nil {
An extended fix could be returning a specific error (e.g. ErrInvalidTodo
) in GithubCredentials.getIssue
when the ID
is empty.
Lines 35 to 47 in 72ba10c
@ankokovin if you would like to you can go ahead and create a PR.
ankokovin commented
Checked again, can confirm that if file has an "unreported todo" this error happens.