Skip to content

Logging template string without extra arguments crashes Sentry logger #4975

@piotrpenar

Description

@piotrpenar

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.42.1

Steps to Reproduce

  1. Install sentry 2.24.1
  2. Try to run:
from sentry_sdk import logger
logger.debug("any text with {braces} in it")
  1. Sentry will raise uncaught exception:
 File ".venv\Lib\site-packages\sentry_sdk\logger.py", line 54, in _capture_log
    "body": template.format(**kwargs),
            ~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'braces'

This has major impact on any app trying to log for example json as raw text.

This is a new bug, introduced in 2.42.x

Expected Result

Sentry should not crash when logging template strings

Actual Result

venv\Lib\site-packages\sentry_sdk\logger.py", line 54, in _capture_log
    "body": template.format(**kwargs),
            ~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'braces'

Metadata

Metadata

Assignees

Labels

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions