Skip to content
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

fix(parser): make size and etag optional for LifecycleExpiration events in S3 #5250

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions aws_lambda_powertools/utilities/parser/models/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ class S3RecordModel(BaseModel):
def validate_s3_object(cls, values):
event_name = values.get("eventName")
s3_object = values.get("s3").get("object")
if "ObjectRemoved" not in event_name and (s3_object.get("size") is None or s3_object.get("eTag") is None):
raise ValueError("S3Object.size and S3Object.eTag are required for non-ObjectRemoved events")
if ":Delete" not in event_name and (s3_object.get("size") is None or s3_object.get("eTag") is None):
raise ValueError(
"Size and eTag fields are required for all events except ObjectRemoved:* and LifecycleExpiration:*.",
)
return values


Expand Down