AWS Lambda functions in Python use boto3
, the AWS SDK, to communicate with other AWS services. boto3
operations can fail
due to service-specific reasons like:
- A requested s3 object does not exist
- Insufficient permissions
- Service rate limit
- Network glitches and other temporary service issues
These errors are typically surfaced as botocore.exceptions.ClientError
. Failing to handle these exceptions correctly by not catching
them or using a broad try/except
block can undermine the lambda function’s reliability and ease of debugging.
What is the potential impact?
Not catching and appropriately handling botocore.exceptions.ClientError
in AWS Lambda functions can lead to:
- Opaque dead letter queue messages
- Suppressed retries
- Unclear root causes in log messages
- Poor API responses
- Silent failures when errors are caught and ignored
- Wasted resources by retrying operations that fail and are not properly handled