Skip to content

fix(client): Normalize span description whitespace before before_send…

e804242
Select commit
Loading
Failed to load commit list.
Merged

ref(asyncpg): Normalize query whitespace in integration #5855

fix(client): Normalize span description whitespace before before_send…
e804242
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Mar 24, 2026 in 2m 2s

1 issue

code-review: Found 1 issue (1 medium)

Medium

Runtime error when span description is None - `sentry_sdk/client.py:718-720`

The _clean_span_descriptions method calls re.sub() on s["description"] after checking if "description" in s, but description can be None (spans are created via to_json() which always includes "description": self.description, even when the description is None). This will raise TypeError: expected string or bytes-like object, got 'NoneType'. Since the call to _clean_span_descriptions is outside the capture_internal_exceptions() context manager, this exception could cause event processing to fail.


Duration: 2m · Tokens: 394.0k in / 5.4k out · Cost: $0.57 (+extraction: $0.00, +fix_gate: $0.00)

Annotations

Check warning on line 720 in sentry_sdk/client.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Runtime error when span description is None

The `_clean_span_descriptions` method calls `re.sub()` on `s["description"]` after checking `if "description" in s`, but `description` can be `None` (spans are created via `to_json()` which always includes `"description": self.description`, even when the description is None). This will raise `TypeError: expected string or bytes-like object, got 'NoneType'`. Since the call to `_clean_span_descriptions` is outside the `capture_internal_exceptions()` context manager, this exception could cause event processing to fail.