Description
How do you use Sentry?
Self-hosted/on-premise
Version
2.23.0+
Steps to Reproduce
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.
Use the following script: repro.txt
We're fairly certain that this comes from the change in 4c9731b which iterates the dict giving only the keys.
Examples where this pattern is used:
- gunicorn, https://github.com/benoitc/gunicorn/blob/a86ea1e4e6c271d1cd1823c7e14490123f9238fe/gunicorn/glogging.py#L362
- ipython, https://github.com/ipython/ipykernel/blob/5802cea49b204f42e326da793426083cbb1469aa/ipykernel/kernelbase.py#L491
Expected Result
Run it with sentry-sdk==2.22.0 and it works fine:
$ 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')
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status