phrase / phraseapp-client

Phrase API Command Line Client

Home Page:https://phrase.com/cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nil pointer dereference in update checking

alexanderwilling opened this issue · comments

From bugsnag:

*errors.Error runtime error: invalid memory address or nil pointer dereference 
    /go/src/github.com/phrase/phraseapp-client/check_for_update.go:42 CheckForUpdate
    main.go:31 Run
    main.go:13 main
    runtime/proc.go:183 main
    runtime/asm_amd64.s:2086 goexit

The problem is getLatestVersion dropping the error of calling getLatestVersionFromCache and always returning nil as err, even when version was nil, too.

I would say we should explicitly add a third boolean parameter to all actions returning a semantic version which marks if it is a valid result (that is != nil) to not rely on people remembering that they can get nil, nil as a result.

Nono, returning nil, nil should never happen. It happened in this case, which is why I opened the issue and PR #80. After that, if err == nil, then version != nil.

then I would stuck with return version, nil, opinion on that?

this will also make the intend clearer

Oh yeah, now I get it, you're right. I updated the PR here: 3853b02