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

Bug: There is no sequencer property in S3 LifecycleTransition event #6150

Closed
DKurilo opened this issue Feb 23, 2025 · 5 comments · Fixed by #6154
Closed

Bug: There is no sequencer property in S3 LifecycleTransition event #6150

DKurilo opened this issue Feb 23, 2025 · 5 comments · Fixed by #6154
Assignees
Labels
bug Something isn't working parser Parser (Pydantic) utility

Comments

@DKurilo
Copy link
Contributor

DKurilo commented Feb 23, 2025

Expected Behaviour

Parsed s3 event when parsing LifecycleTransition event

Current Behaviour

Parsing error. Actually for LifecycleTransition I see many errors.

Code snippet

import json

from aws_lambda_powertools.utilities.parser import parse
from aws_lambda_powertools.utilities.parser.models import S3RecordModel

def main():
    event = '{"eventVersion":"2.3","eventSource":"aws:s3","awsRegion":"us-east-1","eventTime":"2025-02-21T21:46:45.775Z","eventName":"LifecycleTransition","userIdentity":{"principalId":"s3.amazonaws.com"},"requestParameters":{"sourceIPAddress":"s3.amazonaws.com"},"responseElements":{"x-amz-request-id":"something-1","x-amz-id-2":"something-2"},"s3":{"s3SchemaVersion":"1.0","configurationId":"some-sns","bucket":{"name":"bucket-name","ownerIdentity":{"principalId":"PRICIPAL"},"arn":"arn:aws:s3:::bucket-name"},"object":{"key":"/path/to/file.parquet","size":12345,"eTag":"abcdef1232423423","versionId":"SomeThingThere"}},"lifecycleEventData":{"transitionEventData":{"destinationStorageClass":"INTELLIGENT_TIERING"}}}'
    print(str(parse(event=json.loads(event), model=S3RecordModel)))

if __name__ == "__main__":
    main()

Possible Solution

This line
https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/utilities/parser/models/s3.py#L26
can be:

    sourceIPAddress: Union[IPvAnyNetwork, Literal["s3.amazonaws.com"]]

and this line:
https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/utilities/parser/models/s3.py#L48

    sequencer: Optional[str] = None

Steps to Reproduce

Copy code snippet and run it.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.9

Packaging format used

PyPi

Debugging logs

@DKurilo DKurilo added bug Something isn't working triage Pending triage from maintainers labels Feb 23, 2025
@leandrodamascena
Copy link
Contributor

Hi @DKurilo! Thanks for opening this issue and reporting this bug! I can confirm that the value of sourceIPAddress can be an IP or s3.amazonaws.com and we are missing that. Also, for the sequencer, this is only expected for events that create objects (PUTs) and delete objects and not for lifecycle events.

Do you want to submit a PR to fix this?

@leandrodamascena leandrodamascena added parser Parser (Pydantic) utility and removed triage Pending triage from maintainers labels Feb 24, 2025
@leandrodamascena leandrodamascena changed the title There is no sequencer property in S3 LifecycleTransition event Bug: There is no sequencer property in S3 LifecycleTransition event Feb 24, 2025
@DKurilo
Copy link
Contributor Author

DKurilo commented Feb 24, 2025

Hi @leandrodamascena ,
Sure, I'll do it today later.
Do you want me to add validator for sequencer?

@leandrodamascena
Copy link
Contributor

Hey @DKurilo! I don't think we need a validator since there are many variations of eventName, and we might miss something, leading to another bug. Making it Optional, as you suggested, should be sufficient.

I'm assigning this issue to you! Thanks.

@DKurilo
Copy link
Contributor Author

DKurilo commented Feb 24, 2025

Here is PR: #6154

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.

@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Parser (Pydantic) utility
Projects
Status: Shipped
2 participants