I activated partial batch response for my AWS Lambda function that has Amazon Simple Queue Service (Amazon SQS) configured as an event source. My Lambda function returned a list of ReportBatchItemFailures response types.
Short description
After I received a list of ReportBatchItemFailures response types, Lambda either retries an entire message batch or doesn't retry any of the partial message batches.
Note: To programmatically process partial Amazon SQS batches, you must activate partial batch response on your Lambda function. For more information, see Implementing partial batch responses.
Resolution
Review the partial batch response in your Lambda function code to see if there are any of the following response types. Then, remediate the issue based on the response that's recorded.
Note: The following examples are for Python. For examples of function code that returned partial batch responses for other language types, see Handling errors for an SQS event source in Lambda.
Troubleshoot ReportBatchItemFailures where Lambda retries an entire message batch when there wasn't a function error
Note: Lambda treats a batch as a complete success when your function returns any of the following responses.
Responses for an EventResponse that isn't valid JSON
return "Hello world"
return ""
Response for an empty itemIdentifier value
return {"batchItemFailures":[{"itemIdentifier": ""}]}
Response for a null itemIdentifier value
return {"batchItemFailures":[{"itemIdentifier": None}]}
Response for an itemIdentifier value with an incorrect key name
return {"batchItemFailures":[{"bad_key": messageID}]}
Response for an itemIdentifier value with a message ID that doesn't exist
return {"batchItemFailures":[{"itemIdentifier": "random_ID"}]}
Important: Your Lambda function must return a valid itemIdentifier JSON value.
Troubleshoot ReportBatchItemFailures where Lambda doesn't retry any of the partial message batches
Note: Lambda treats a batch as a complete success when your function returns any of the following responses.
Response for an empty batchItemFailures list
return {"batchItemFailures":[]}
Response for a null batchItemFailures list
return {"batchItemFailures": None}
Responses for an EventResponse with an empty or unexpected JSON value
return {}
return {"Key1":"Value1"}
Responses for a null EventResponse
return
return None
Important: Your Lambda function must return a response that includes a batchItemFailures JSON value and a list of valid message IDs.
Related information
How can I prevent an Amazon SQS message from invoking my Lambda function more than once?
Using Lambda with Amazon SQS