-
Notifications
You must be signed in to change notification settings - Fork 402
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
Logger: log_event does not serialize classes #947
Comments
Thanks @kishaningithub . I will take a look at that. We had a related fix for idempotency. For now inverting the decorators: @log.inject_lambda_context(log_event=True)
@event_source(data_class=S3Event)
def lambda_handler(event: S3Event, context: LambdaContext):
pass |
hey @kishaningithub thanks for raising that. The main reason we didn't do this is that these are untrusted strings. We weren't certain of the potential attack vectors this could cause (similar but not the same to Log4j). Besides the fix of inverting the decorator, I'd be cautious on doing this in production as you might dump sensitive data into the logs. All that being said, you can bring your own JSON serializer for Logger via LambdaPowertoolsFormatter - this would be an explicit way to opt-in to serialize any data you want. Keen to hear your thoughts Thank you! |
Changes: - Add dict data from raw_event when available closes aws-powertools#947
Updating here as @michaelbrewer promptly created a PR to only log IF they're an instance of our built-in event source data classes. I'm fine with this compromise since the only vector here would be a customer to override our data classes |
This is now released under 1.25.0 version! |
What were you trying to accomplish?
I was trying to log the received S3 event. Please note that i am using the data classes present in this library for reading the event
Expected Behavior
The logged event should have all the information from the S3 event
Current Behavior
This is the output i get in the log (trimmed)
It looks to be that it was unable to properly represent the S3Event object as a string
Possible Solution
Implement repr and str methods in S3Event class or in the parent DictWrapper class
Steps to Reproduce (for bugs)
Environment
# paste logs here
The text was updated successfully, but these errors were encountered: