You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Log formatting with %s now can't output dicts #4267
We've observed cases in open source where a dict is passed positionally to a logging call. A recent change in sentry means that params loses its dict-ness and is only keys by the time it gets to before_send. This can result in "format requires a mapping" or "not all arguments converted during string formatting" exceptions.
$ python repro.py
INFO:test-logger:test {'hello': 'world', 'foo': 'bar'}
INFO:test-logger:test world
Actual Result
If you run it with sentry-sdk==2.23.1 or newer, it's broken:
$ python repro.py
INFO:test-logger:test {'hello': 'world', 'foo': 'bar'}
WARNING:sentrybugrepro:Failed to set formatted message for '{'message': 'test %s', 'params': ['hello', 'foo']}'. exception: TypeError('not all arguments converted during string formatting')
INFO:test-logger:test world
WARNING:sentrybugrepro:Failed to set formatted message for '{'message': 'test %(hello)s', 'params': ['hello', 'foo']}'. exception: TypeError('format requires a mapping')
It indeed looks like the Python SDK stopped sending dictionary values with logging events sometime after 2.22.0. I agree, 4c9731b seems like the likeliest cause.
Activity
thatch commentedon Apr 9, 2025
Probably also relevant:
https://github.com/python/cpython/blob/d687900f98114bb5910daad9553ae381d7daf94b/Lib/logging/__init__.py#L307-L327
szokeasaurusrex commentedon Apr 11, 2025
Thanks for the report, we will investigate
szokeasaurusrex commentedon Apr 14, 2025
@thatch thanks for the report.
It indeed looks like the Python SDK stopped sending dictionary values with logging events sometime after 2.22.0. I agree, 4c9731b seems like the likeliest cause.
fix(logging): Send raw logging parameters
fix(logging): Send raw logging parameters