lifadev / archive_aws-lambda-go-shim

Author your AWS Lambda functions in Go, effectively.

Home Page:https://github.com/eawsy/aws-lambda-go-shim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with "error" values

bfreis opened this issue · comments

Hi!

I've identified an issue with "error" return values. If my Golang handler returns an error, the Lambda function invocation still completes successfully. That is, the Python shim isn't reporting an error to the Lambda runtime - instead, it is ending successfully, returning an object like {"errorMessage": "whatever"}.

It seems like the Lambda dashboard does indeed renders this as an error, however the execution is still reported to have been completed successfully.

I noticed this when I first tried to integrate a Golang Lambda function with the recently released AWS Step Functions service. Step Functions error detection mechanism for Task states running a Lambda function depend on the Lambda function correctly reporting error conditions. I wrote a very simple Golang Lambda handler function that would simply return nil, errors.New("blah"), and I noticed that a State Machine invoking that task would complete successfully, with the successful output being reported as {"errorMessage": ...}. The expected result would be for the State Machine execution to fail. I then wrote a trivial pure Python handler that would simply throw an error, and the State Machine did identify the error.

It seems like something that's not easy to fix... but I could be wrong.

Any ideas?

Cheers!

Hi @bfreis,

We've found this bug yesterday in production. And fixed it today. Fix coming in a few hours I think.

Whoa! Amazing :)

Thanks!

The problem comes from a misunderstanding of the AWS Lambda bootstrap.py (source code available in your Lambda, but cannot disclose it for AWS copyright reasons). Basically bootstrap.py interprets the result of the execution of user code, catch exceptions if any and then build an answer for the underlying AWS.
If errors happen, the result sent to runtime is {"errorMessage": "..."}. By sending this message ourselves to the bootstrap.py, we've achieved a nearly transparent error handling for Go.
BUT
There's a bug in the AWS Lambda console. When you send this message, the console shows a red error message as if there were a real error, but in fact it is just syntax/color sugar and lead to error because AWS Lambda does not considers it as a real error.

@bfreis new image with fixed shim inside pushed. Please pull to update your local image and it should be OK 😉 .

PS: A brand new version, ready for production, coming next week. Keep connected.

Fantastic, just tested it with Step Functions and I can confirm the errors are indeed being passed to Lambda (and then to Step Functions) properly!

Also - thanks for updating to the final Go 1.8 runtime!

Cheers
Bruno