Skip to content

Bug: S3 SQS Event Parsing for LifecycleExpiration:Delete is failed #5129

Closed
@DKurilo

Description

@DKurilo
Contributor

Expected Behaviour

LifecycleExpiration:Delete events for SQS queue should be parsed properly

Current Behaviour

Error because for all :Delete events size and eTag are not in event and code here is requires it:
https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/utilities/parser/models/s3.py#L108
I added code from link to code snippet

Code snippet

@root_validator(allow_reuse=True, skip_on_failure=True)
    def validate_s3_object(cls, values):
        event_name = values.get("eventName")
        s3_object = values.get("s3").object
        if "ObjectRemoved" not in event_name:
            if s3_object.size is None or s3_object.eTag is None:
                raise ValueError("S3Object.size and S3Object.eTag are required for non-ObjectRemoved events")
        return values

Possible Solution

Change condition from:

        if "ObjectRemoved" not in event_name:

to

        if ":Delete" not in event_name:

Steps to Reproduce

Try to parse LifecycleExpiration:Delete.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.8

Packaging format used

Lambda Layers

Debugging logs

No response

Activity

added
bugSomething isn't working
triagePending triage from maintainers
on Sep 5, 2024
boring-cyborg

boring-cyborg commented on Sep 5, 2024

@boring-cyborg

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

changed the title [-]Bug: S3 SQS Evnet Parsing for LifecycleExpiration:Delete is failedd[/-] [+]Bug: S3 SQS Evnet Parsing for LifecycleExpiration:Delete is failed[/+] on Sep 5, 2024
leandrodamascena

leandrodamascena commented on Sep 9, 2024

@leandrodamascena
Contributor

Hi @DKurilo! Thanks for opening this issue! I'll take a look at it until tomorrow.

moved this from Triage to Pending review in Powertools for AWS Lambda (Python)on Sep 9, 2024
changed the title [-]Bug: S3 SQS Evnet Parsing for LifecycleExpiration:Delete is failed[/-] [+]Bug: S3 SQS Event Parsing for LifecycleExpiration:Delete is failed[/+] on Sep 9, 2024
leandrodamascena

leandrodamascena commented on Sep 10, 2024

@leandrodamascena
Contributor

Hi @am29d! As we discussed yesterday, I'm assigning this issue to you.

14 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

    Participants

    @am29d@leandrodamascena@DKurilo

    Issue actions

      Bug: S3 SQS Event Parsing for LifecycleExpiration:Delete is failed · Issue #5129 · aws-powertools/powertools-lambda-python