Skip to content

fix(batch): Correctly handle child_exceptions being None #1205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 changes: 1 addition & 1 deletion aws_lambda_powertools/utilities/batch/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, msg="", child_exceptions: Optional[List[ExceptionInfo]] = Non

def format_exceptions(self, parent_exception_str):
exception_list = [f"{parent_exception_str}\n"]
for exception in self.child_exceptions:
for exception in self.child_exceptions or []:
extype, ex, tb = exception
formatted = "".join(traceback.format_exception(extype, ex, tb))
exception_list.append(formatted)
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/test_utilities_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,3 +908,7 @@ def lambda_handler(event, context):

# THEN raise BatchProcessingError
assert "All records failed processing. " in str(e.value)


def test_child_exceptions_is_none():
assert str(SQSBatchProcessingError()) == "\n"