When a lambda handler with several return values is wrapped using LambdaWrapper, and a panic is called from inside the handler, runtime error "reflect: wrong return count from function created by MakeFunc" occurs
Example of lambda handler:
client.LambdaWrapper(func() (string, error) {
panic(err)
})
Here's a unit test to prove the bug
#client_test.go
func TestLambdaWrapperWithErrorAndMultipleReturnValues(t *testing.T) {
client := testClient()
err := errors.New("bork")
defer func() {
recoveredError := recover()
if recoveredError != err {
if recoveredError == nil {
t.Error("Expected wrapper to bubble up the custom panic error")
} else {
t.Errorf("Unexpected panic %s", recoveredError)
}
}
if transport, ok := client.Transport.(*TestTransport); ok {
if transport.Body == nil {
t.Error("Expected Body to be present")
}
if !transport.WaitCalled {
t.Error("Expected wait to be called")
}
} else {
t.Fail()
}
}()
handler := client.LambdaWrapper(func() (string, error) {
panic(err)
return "", nil
})
fn := reflect.ValueOf(handler)
var args []reflect.Value
fn.Call(args)
}
When a lambda handler with several return values is wrapped using
LambdaWrapper, and apanicis called from inside the handler, runtime error "reflect: wrong return count from function created by MakeFunc" occursExample of lambda handler:
Here's a unit test to prove the bug
#client_test.go