When data from the body property of a request from ApiGatway is base64 encoded, it is not being read correctly and an exception is thrown.
More details
When using protobot/serverless-lambda inside an AWS lambda function via and AWS ApiGatway proxy integration, the request body may be sent to the function as a base64 encoded string. The event data contains a dedicated field, isBase64Encoded, meant to indicate this. This field is not being read, and so we make an attempt to parse the body as JSON without decoding it first, causing an exception to be thrown.
Quick workaround
Replacing the handler.js example suggested in the readme with something like this solves the issue -
In short
When data from the
body
property of a request from ApiGatway is base64 encoded, it is not being read correctly and an exception is thrown.More details
When using
protobot/serverless-lambda
inside an AWS lambda function via and AWS ApiGatway proxy integration, the request body may be sent to the function as a base64 encoded string. The event data contains a dedicated field,isBase64Encoded
, meant to indicate this. This field is not being read, and so we make an attempt to parse the body as JSON without decoding it first, causing an exception to be thrown.Quick workaround
Replacing the
handler.js
example suggested in the readme with something like this solves the issue -