From 6919c7c4aa9b5a8a29f2f2cf4f5485175674082d Mon Sep 17 00:00:00 2001 From: Igor Anic Date: Fri, 3 Dec 2021 11:05:08 +0100 Subject: [PATCH] fix unhandled error leading to the panic In the case when connection to the NGS is refused. ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1f590b4] goroutine 1 [running]: github.com/mantil-io/mantil/cli/controller/invoke.(*LambdaClient).Do(0xc000663a10, {0x2403a72, 0x6}, {0x218bf40, 0xc000438000}, {0x218bf80, 0xc000afc020}) github.com/mantil-io/mantil/cli/controller/invoke/invoke.go:239 +0x134 github.com/mantil-io/mantil/cli/controller.(*Setup).create(0xc000414f00, 0xc00020cc40) github.com/mantil-io/mantil/cli/controller/setup.go:133 +0x3c8 github.com/mantil-io/mantil/cli/controller.(*Setup).Create(0xc000414f00, 0xc0005a5c20) github.com/mantil-io/mantil/cli/controller/setup.go:91 +0x325 github.com/mantil-io/mantil/cli/cmd.newAwsInstallCommand.func1(0xc0003bd400, {0xc0003a27c0, 0x2, 0x2}) github.com/mantil-io/mantil/cli/cmd/commands.go:80 +0x1a7 github.com/spf13/cobra.(*Command).execute(0xc0003bd400, {0xc0003a27a0, 0x2, 0x2}) github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e github.com/spf13/cobra.(*Command).ExecuteC(0xc000377680) github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc github.com/mantil-io/mantil/cli/cmd.Execute() github.com/mantil-io/mantil/cli/cmd/root.go:24 +0x3e main.run() github.com/mantil-io/mantil/cli/main.go:75 +0x275 main.main() github.com/mantil-io/mantil/cli/main.go:27 +0x2e ``` --- cli/controller/invoke/invoke.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cli/controller/invoke/invoke.go b/cli/controller/invoke/invoke.go index 5117df4d..53e9e7aa 100644 --- a/cli/controller/invoke/invoke.go +++ b/cli/controller/invoke/invoke.go @@ -219,6 +219,9 @@ func Lambda(invoker Invoker, functionName string, logSink LogSinkCallback) *Lamb func (l *LambdaClient) Do(method string, req, rsp interface{}) error { lsn, err := newListener(nil, rsp, l.logSink) + if err != nil { + return err + } var payload []byte if req != nil {