Panic when invoking function with --async option
totem3 opened this issue · comments
Current Behavior
Invoking function with --async
option causes panic.
Error logs are as follows:
log
❯ echo '{"Name":"lambroll"}' | lambroll invoke --region ap-northeast-1 --log-level trace --async
2020/01/13 21:51:30 [info] lambroll v0.3.2
2020/01/13 21:51:30 [debug] invoking function {
FunctionName: "lambroll-sample",
InvocationType: "Event",
Payload: <binary> len 19
}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x15f02a8]
goroutine 1 [running]:
github.com/fujiwara/lambroll.(*App).Invoke(0xc000081780, 0xc000089c90, 0xc0000a8e76, 0xc0000a8e77, 0x0, 0xc000089da0)
/home/runner/work/lambroll/lambroll/invoke.go:69 +0x628
main._main(0xc000086058)
/home/runner/work/lambroll/lambroll/cmd/lambroll/main.go:103 +0x26de
main.main()
/home/runner/work/lambroll/lambroll/cmd/lambroll/main.go:17 +0x22
same function works as expected without --async
option.
Cause
Panic is caused by dereferencing res.ExecutedVersion
, which is not included in response when invocation type is Event
.
It seems Lambda Invoke API returns only StatusCode
when invocation type is Event
.
cf.
- https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html
- https://docs.aws.amazon.com/cli/latest/reference/lambda/invoke.html
How to reproduce
- init function
- deploy function
- invoke function with
--async
option
Environment
lambroll version: v0.3.2 ( and b9a4c02 built with go 1.13)
OS: macOS 10.14.6