-
Notifications
You must be signed in to change notification settings - Fork 153
fix(logger): prevent overwriting standard keys #3553
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
Conversation
Ran e2e tests and they're passing. |
I'll review this today morning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dreamorosi, I left a comment about protected keys.
Another thing is that even I consider this a bug because the customer may end up having some logs with level: 'BLABLA
and this is not a valid log level + we should enforce good practices. But this is a breaking change both in terms of possible data loss and in the customers' CI with warnings
popping up in their pipeline and possible breaking this. We must highlight this in the documentation/release notes and monitor if we have customers complaining.
My vote is to move forward with this PR, but monitor the feedback after releasing it.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for improving the PR based on feedback and helping customers identify potential issues before pushing code to production.
Approved.
Summary
Changes
This PR fixes a bug that allowed customer payloads to override Powertools-managed keys in logs.
Logger has a set of keys that are added to every log entry, for example
level
,timestamp
,service
, and more. These keys are what make logs discoverable.Due to a bug, in some cases when customers appended keys to the Logger instance or passed extra keys to a log method, some of the service keys would be overridden by the customer-provided keys.
For example:
In this case the
level
key from the user object would override the level in the log entry.This PR fixes this bug and makes it so that when a customer-provided key conflicts with a reserved key, Logger will drop the customer one and log a warning.
Issue number: fixes #3217
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.