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

Extend LOG003 disallowed extra keys to include message #77

Merged
merged 5 commits into from
Jan 23, 2024

Conversation

vartec
Copy link
Contributor

@vartec vartec commented Dec 15, 2023

LogRecord specifically disallows two Formatter's params "message" and "asctime" in extra:
https://github.com/python/cpython/blob/d07483292b115a5a0e9b9b09f3ec1000ce879986/Lib/logging/__init__.py#L1621-L1623

This PR adds missing "message" missing in LOG003 check.
This will prevent

KeyError "Attempt to overwrite 'message' in LogRecord"

Also added parametrized tests which validate all the keys that should be rejected by LOG003.

@vartec
Copy link
Contributor Author

vartec commented Dec 18, 2023

Hey @adamchainz, this is a fairly minimal, but impactful change.
Any chance you'd be able to have it merged and released before the holidays?

No pressure, I'll understand if you cannot get to it now. I just want to have an estimate.

@vartec
Copy link
Contributor Author

vartec commented Jan 22, 2024

Hi @adamchainz, it's been a while. I'd really appreciate this merged, it's important to prevent these types of bugs for us.

@adamchainz
Copy link
Owner

Please don’t write “ping” messages, I find it really annoying.

@adamchainz adamchainz changed the title (fix) Adding 'message' to keys disallowed in 'extra' (LOG003) Extend LOG003 disallowed extra keys to include message Jan 23, 2024
@adamchainz adamchainz merged commit b48e848 into adamchainz:main Jan 23, 2024
7 checks passed
vartec pushed a commit to getsentry/sentry that referenced this pull request Jan 25, 2024
Bumping flake8-logging to 1.5.0 to include fix for 
```python
KeyError "Attempt to overwrite 'message' in LogRecord"
```

Changelog:
https://github.com/adamchainz/flake8-logging/blob/main/CHANGELOG.rst#150-2024-01-23
Fix: adamchainz/flake8-logging#77
snigdhas pushed a commit to getsentry/sentry that referenced this pull request Jan 26, 2024
Bumping flake8-logging to 1.5.0 to include fix for 
```python
KeyError "Attempt to overwrite 'message' in LogRecord"
```

Changelog:
https://github.com/adamchainz/flake8-logging/blob/main/CHANGELOG.rst#150-2024-01-23
Fix: adamchainz/flake8-logging#77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants