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 completed Mar 24, 2026 in 3m 18s

2 issues

High

TypeError crash when span description is None - `sentry_sdk/client.py:718-719`

The _clean_span_descriptions method checks if "description" in s: which only verifies the key exists, not that its value is non-None. When s["description"] is None (which is valid per the span serialization at tracing.py:702), calling re.sub(r"\s+", " ", s["description"]) raises TypeError: expected string or bytes-like object, got 'NoneType'. Since this code runs outside capture_internal_exceptions(), the error will propagate and could crash transaction processing.

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.

4 skills analyzed
Skill Findings Duration Cost
code-review 1 2m $0.56
find-bugs 1 3m 12s $1.39
skill-scanner 0 29.2s $0.19
security-review 0 48.8s $0.44

Duration: 6m 29s · Tokens: 1.6M in / 17.6k out · Cost: $2.59 (+extraction: $0.00, +fix_gate: $0.01, +dedup: $0.00)