Skip to content

Bug: process_partial_response or processor does not catch raised errors in subroutine #4349

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
mhboon opened this issue May 17, 2024 · 4 comments
Labels
batch Batch processing utility need-more-information Pending information to continue not-a-bug

Comments

@mhboon
Copy link

mhboon commented May 17, 2024

Expected Behaviour

Inline with the provided examples:
https://docs.powertools.aws.dev/lambda/python/latest/utilities/batch/#accessing-processed-messages and https://docs.powertools.aws.dev/lambda/python/latest/utilities/batch/#recommended

the expected behavior is that in case record_handler raises and exception. either processor or process_partial_response catches this for further controlled handling.

Current Behaviour

In case record_handler raises an exception, this results in a BatchProcessingError

Code snippet

def record_handler(record: SQSRecord):
    raise Exception("not ok")
def lambda_handler(event, context: LambdaContext):
    return process_partial_response(  
        event=event,
        record_handler=record_handler,
        processor=processor,
        context=context,
    )

Possible Solution

No response

Steps to Reproduce

Not yet tested when running in a lambda; reproduced when running locally.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.8

Packaging format used

Lambda Layers

Debugging logs

No response

@mhboon mhboon added bug Something isn't working triage Pending triage from maintainers labels May 17, 2024
Copy link

boring-cyborg bot commented May 17, 2024

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@heitorlessa
Copy link
Contributor

Hey @mhboon, that's the expected behaviour when all records in the batch fail to be processed.

https://docs.powertools.aws.dev/lambda/python/latest/utilities/batch/#partial-failure-mechanics

If you however have a partial failure, that is one successful amongst many failures, then it won't raise.

We do raise in total failure scenarios with all exceptions collected to help you diagnose an unwanted scenario. For poison pills, partial failures, etc. we handle just as fine.

Does that help? Or did you notice a regression and an exception is being raised despite a partial success?

@heitorlessa heitorlessa added need-more-information Pending information to continue not-a-bug batch Batch processing utility and removed bug Something isn't working triage Pending triage from maintainers labels May 17, 2024
@heitorlessa heitorlessa moved this from Triage to Pending customer in Powertools for AWS Lambda (Python) May 17, 2024
@mhboon
Copy link
Author

mhboon commented May 17, 2024

Got it; in that case, I misunderstood and will close the issue. Thanks for clarifying.

@mhboon mhboon closed this as completed May 17, 2024
@github-project-automation github-project-automation bot moved this from Pending customer to Coming soon in Powertools for AWS Lambda (Python) May 17, 2024
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@heitorlessa heitorlessa moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
batch Batch processing utility need-more-information Pending information to continue not-a-bug
Projects
Status: Shipped
Development

No branches or pull requests

2 participants