Skip to content

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

Closed
@DKurilo

Description

@DKurilo

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions