Skip to content

move imports

9648022
Select commit
Loading
Failed to load commit list.
Merged

feat(wsgi): Migrate to span first #5988

move imports
9648022
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed Apr 13, 2026 in 4m 44s

2 issues

find-bugs: Found 2 issues (1 high, 1 medium)

High

Circular import between _wsgi_common.py and wsgi.py will cause ImportError - `sentry_sdk/integrations/_wsgi_common.py:8`

The new import from sentry_sdk.integrations.wsgi import get_client_ip, get_request_url at module level creates a circular dependency. When _wsgi_common.py is imported first (e.g., via flask.py, bottle.py, or other integrations that import from _wsgi_common before wsgi), Python tries to load wsgi.py which in turn imports _get_request_attributes from the partially-initialized _wsgi_common module. This results in ImportError: cannot import name '_get_request_attributes' from partially initialized module 'sentry_sdk.integrations._wsgi_common'.

Medium

AttributeError when HTTP method not in http_methods_to_capture - `sentry_sdk/integrations/wsgi.py:167`

When the HTTP request method is not in http_methods_to_capture (e.g., HEAD, OPTIONS), span_ctx defaults to nullcontext() which yields None as the span value. The code then attempts to call span.set_attribute(attr, value) on None, causing an AttributeError. While this exception is caught by capture_internal_exceptions(), it will log an internal SDK error for every HEAD/OPTIONS request and silently fail to set request attributes.


Duration: 4m 41s · Tokens: 3.0M in / 25.9k out · Cost: $3.97 (+extraction: $0.01, +merge: $0.00)

Annotations

Check failure on line 8 in sentry_sdk/integrations/_wsgi_common.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

Circular import between _wsgi_common.py and wsgi.py will cause ImportError

The new import `from sentry_sdk.integrations.wsgi import get_client_ip, get_request_url` at module level creates a circular dependency. When `_wsgi_common.py` is imported first (e.g., via flask.py, bottle.py, or other integrations that import from `_wsgi_common` before `wsgi`), Python tries to load `wsgi.py` which in turn imports `_get_request_attributes` from the partially-initialized `_wsgi_common` module. This results in `ImportError: cannot import name '_get_request_attributes' from partially initialized module 'sentry_sdk.integrations._wsgi_common'`.

Check warning on line 167 in sentry_sdk/integrations/wsgi.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

AttributeError when HTTP method not in http_methods_to_capture

When the HTTP request method is not in `http_methods_to_capture` (e.g., HEAD, OPTIONS), `span_ctx` defaults to `nullcontext()` which yields `None` as the `span` value. The code then attempts to call `span.set_attribute(attr, value)` on `None`, causing an `AttributeError`. While this exception is caught by `capture_internal_exceptions()`, it will log an internal SDK error for every HEAD/OPTIONS request and silently fail to set request attributes.