tessl install tessl/pypi-aws-lambda-powertools@3.19.0Comprehensive developer toolkit implementing serverless best practices for AWS Lambda functions in Python
Agent Success
Agent success rate when using this tile
89%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.22x
Baseline
Agent success rate without this tile
73%
Build a Lambda function that processes incoming order events from an SQS queue. The function should validate and process each order, handle failures gracefully, and only report back messages that could not be successfully processed.
Your Lambda handler will receive multiple order messages in a single invocation. Each order must be processed independently, and partial failures must be reported so that only failed messages are returned to the queue for retry.
Each order message contains JSON data with the following fields:
order_id (string): Unique order identifiercustomer_id (string): Customer identifieritems (array): List of items being orderedtotal_amount (number): Total order amountThe function should:
total_amount is less than 0 (treat as validation failure)items array is empty (treat as validation failure)For valid orders:
"Processing order {order_id} for customer {customer_id}"order_id contains the string "fail" (case-insensitive)
@generates
def lambda_handler(event: dict, context) -> dict:
"""
Lambda handler that processes SQS order messages with partial failure handling.
Args:
event: Lambda event containing SQS records
context: Lambda context object
Returns:
dict with batchItemFailures for messages that failed processing
"""
pass
def process_order(order_data: dict) -> None:
"""
Process a single order after validation.
Args:
order_data: Parsed order data dictionary
Raises:
Exception: If order processing fails
"""
passProvides utilities for AWS Lambda best practices including batch processing with partial failure handling.
@satisfied-by