Commit 53249b3
fix(tracing_utils): handle baggage values containing '=' in from_incoming_header (#6450)
## What's broken
`Baggage.from_incoming_header` silently drops any sentry baggage item
whose value contains an `=` character (e.g. base64-encoded strings like
`v1.0==1`). A header like
`sentry-release=v1.0==1,sentry-trace_id=abc123` produces `{'trace_id':
'abc123'}` instead of `{'release': 'v1.0==1', 'trace_id': 'abc123'}`.
## Why it happens
`key, val = item.split("=")` without a `maxsplit` argument raises
`ValueError: too many values to unpack` when the value contains `=`. The
surrounding `capture_internal_exceptions()` swallows the exception,
silently discarding the item.
## Fix
Changed `item.split("=")` to `item.split("=", 1)` so the split stops
after the first delimiter, correctly assigning the key and the full
value (including any `=` in the value).
## Test
Added `test_baggage_from_incoming_header_value_with_equals_sign` which
parses a header containing a sentry item with `==` in its value and
asserts both items are present in `sentry_items`.
Fixes #6449
Co-authored-by: Aegis Dev <devteamaegis@users.noreply.github.com>
Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>1 parent 41ff92e commit 53249b3
2 files changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
722 | | - | |
| 722 | + | |
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
0 commit comments