Skip to content

Commit e716097

Browse files
authored
Skip malformed baggage items (#1491)
We are seeing baggage headers coming in with a single comma. This is obviously invalid but Sentry should error out.
1 parent 9e69fcf commit e716097

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

sentry_sdk/tracing_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ def from_incoming_header(cls, header):
457457

458458
if header:
459459
for item in header.split(","):
460+
if "=" not in item:
461+
continue
460462
item = item.strip()
461463
key, val = item.split("=")
462464
if Baggage.SENTRY_PREFIX_REGEX.match(key):

tests/tracing/test_baggage.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ def test_mixed_baggage():
6565
"other-vendor-value-1=foo;bar;baz,other-vendor-value-2=foo;bar;"
6666
).split(",")
6767
)
68+
69+
70+
def test_malformed_baggage():
71+
header = ","
72+
73+
baggage = Baggage.from_incoming_header(header)
74+
75+
assert baggage.sentry_items == {}
76+
assert baggage.third_party_items == ""
77+
assert baggage.mutable

0 commit comments

Comments
 (0)