Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): callbacks panic when response is nil (#486)
I have spotted a panic dusing the execution of CLI commands, the problem is that we never checked if the `response` comes back as a `nil` pointer and we try to access it anyway: ``` === FAIL: api TestCallbacksOnRequestError (0.00s) panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x131c784] goroutine 132 [running]: testing.tRunner.func1.2(0x1404500, 0x1703d50) /usr/local/go/src/testing/testing.go:1143 +0x332 testing.tRunner.func1(0xc0003f4f00) /usr/local/go/src/testing/testing.go:1146 +0x4b6 panic(0x1404500, 0x1703d50) /usr/local/go/src/runtime/panic.go:965 +0x1b9 github.com/lacework/go-sdk/api.(*Client).Do(0xc00013a340, 0xc000076100, 0x3, 0x14749dc, 0x3) /Users/salimmaya/go/src/github.com/lacework/go-sdk/api/http.go:179 +0xe4 github.com/lacework/go-sdk/api_test.TestCallbacksOnRequestError(0xc0003f4f00) /Users/salimmaya/go/src/github.com/lacework/go-sdk/api/callbacks_test.go:85 +0x3af testing.tRunner(0xc0003f4f00, 0x149c520) /usr/local/go/src/testing/testing.go:1193 +0xef created by testing.(*T).Run /usr/local/go/src/testing/testing.go:1238 +0x2b3 DONE 338 tests, 1 failure in 2.649s make: *** [test] Error 1 ``` Signed-off-by: Salim Afiune Maya <[email protected]>
- Loading branch information