Skip to content

Commit a70c181

Browse files
author
Michael Brewer
authored
fix(batch): bugfix to clear exceptions between executions (#1022)
1 parent 77f86c0 commit a70c181

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Diff for: aws_lambda_powertools/utilities/batch/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ def _prepare(self):
351351
"""
352352
self.success_messages.clear()
353353
self.fail_messages.clear()
354+
self.exceptions.clear()
354355
self.batch_response = copy.deepcopy(self.DEFAULT_RESPONSE)
355356

356357
def _process_record(self, record: dict) -> Union[SuccessResponse, FailureResponse]:

Diff for: tests/functional/test_utilities_batch.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,16 @@ def test_batch_processor_error_when_entire_batch_fails(sqs_event_factory, record
895895
def lambda_handler(event, context):
896896
return processor.response()
897897

898-
# WHEN/THEN
898+
# WHEN calling `lambda_handler` in cold start
899899
with pytest.raises(BatchProcessingError) as e:
900900
lambda_handler(event, {})
901-
ret = str(e)
902-
assert ret is not None
901+
902+
# THEN raise BatchProcessingError
903+
assert "All records failed processing. " in str(e.value)
904+
905+
# WHEN calling `lambda_handler` in warm start
906+
with pytest.raises(BatchProcessingError) as e:
907+
lambda_handler(event, {})
908+
909+
# THEN raise BatchProcessingError
910+
assert "All records failed processing. " in str(e.value)

0 commit comments

Comments
 (0)