Skip to content

fix: pass sentry_logs_level only to sentry-sdk versions that accept it - #244

Merged
lesnik512 merged 1 commit into
mainfrom
fix/sentry-logs-level-floor
Sep 20, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
fix/sentry-logs-level-floor

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Released in 1.8.0 and still in 1.9.0: every Sentry-enabled service on sentry-sdk 2.1 through 2.24
crashes at bootstrap.

TypeError: LoggingIntegration.__init__() got an unexpected keyword argument 'sentry_logs_level'

sentry_instrument.py passed sentry_logs_level=None unconditionally (added in #231). That parameter
arrived in sentry-sdk 2.25.0, bisected against PyPI; the declared floor is sentry-sdk>=2.1.

Reproduced at the floor with a plain config, no test scaffolding:

FreeBootstrapper(bootstrap_config=FreeConfig(service_name="svc", sentry_dsn="...")).bootstrap()

The fix

A capability check computed once at import, rather than raising the floor to >=2.25 and dropping 24
sentry-sdk releases:

SENTRY_LOGS_LEVEL_SUPPORTED: typing.Final = (
    "sentry_logs_level" in inspect.signature(LoggingIntegration.__init__).parameters
)

This is not a workaround for an unsupported keyword. Below 2.25 there is no Sentry Logs feature at
all, so SentryLogsHandler does not exist and there is no wasted formatting to suppress. The saving
#186 shipped is only available where the feature is, and omitting the keyword elsewhere is the
accurate thing to do, not a compromise.

Verified on both sides:

sentry-sdk bootstrap logging integration
2.1.0 (floor) OK, was TypeError _breadcrumb_handler, _handler; no logs handler exists
2.67.1 (current) OK, unchanged logs handler None, so #186's saving still applies

CI would have caught this, one day later

scripts/floor_smoke.py free fails on main with the same TypeError and passes with this change.
It is only reached by the lowest-direct job, which does not run on pull requests, so #231 never
exercised a floor. The daily cadence added in #233 would have opened a tracking issue at 06:00 UTC.

(Measuring that took two attempts: uv pip install <path> is a copied install, not editable, so
swapping the source file under a built venv proves nothing. The result above comes from reinstalling
each version.)

Test

One parametrized invariant over the capability flag: passed when the SDK accepts it, omitted when it
does not. It asserts through _build_integrations() rather than sentry_sdk.init, so it does not
depend on SDK global state.

324 tests, ruff, ty clean.

Wants a 1.9.1 immediately: the current release is broken for anyone not on a recent sentry-sdk.

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.

1 participant