Lambda: Invocation, Function and Runtime Errors

Dashbird continuously monitors and analyses your serverless applications to ensure reliability, cost and performance optimisation and alignment with the Well Architected Framework.

Product Features Start Free Trial

Invocation Errors

An AWS Lambda invocation can raise errors for a variety of reasons1. A few examples are listed below. Invocation errors will make Lambda return a 400-series or 500-series HTTP status code.

For a complete list of invocation errors, please refer to the AWS documentation2.

Event Payload

  • Larger than the Lambda limit3
  • Contains a parameter with invalid type

Request

  • Trying to invoke an inexistent function
  • Client doesn’t have permissions to invoke the required function

AWS Account

  • Account services are suspended
  • Reached the limit of concurrent Lambda microVMs running

Function Errors

AWS Lambda Function errors happen when, for example:

  • Developer’s code raises an exception
  • There is a syntax error in the code preventing the execution
  • The execution reaches the timeout limit

AWS Lambda will automatically add the X-Amz-Function-Error header and a JSON as the response with details about the function error. Because of that, it is a good practice to avoid the code from raising exceptions, since it will expose internal implementation details. This could potentially compromise the application security.

To avoid this issue, developers should catch all exceptions in the function_handler, log them and return a sanitized and gentle response to the requester.

Runtime Errors

AWS provides guidance on handling function exceptions for all runtimes supported by Lambda. Below is list with reference pages for each runtime:


Footnotes


  1. Error Handling and Automatic Retries in AWS Lambda ↩︎
  2. Lambda API Invoke Errors ↩︎
  3. Lambda accepts event payloads with up to 6 MB in synchronous invocations and 256 KB for asynchronous mode ↩︎

No results found