fix(tracing_utils): handle baggage values containing '=' in from_incoming_header#6450
Open
devteamaegis wants to merge 1 commit into
Open
fix(tracing_utils): handle baggage values containing '=' in from_incoming_header#6450devteamaegis wants to merge 1 commit into
devteamaegis wants to merge 1 commit into
Conversation
…e values with '=' characters
Baggage values that contain '=' (e.g. base64-encoded strings) caused
str.split("=") to return more than two parts, raising ValueError which
was silently swallowed by capture_internal_exceptions(), dropping the
sentry baggage item entirely. Fix: item.split("=", 1).
Fixes getsentry#6449
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken
Baggage.from_incoming_headersilently drops any sentry baggage item whose value contains an=character (e.g. base64-encoded strings likev1.0==1). A header likesentry-release=v1.0==1,sentry-trace_id=abc123produces{'trace_id': 'abc123'}instead of{'release': 'v1.0==1', 'trace_id': 'abc123'}.Why it happens
key, val = item.split("=")without amaxsplitargument raisesValueError: too many values to unpackwhen the value contains=. The surroundingcapture_internal_exceptions()swallows the exception, silently discarding the item.Fix
Changed
item.split("=")toitem.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_signwhich parses a header containing a sentry item with==in its value and asserts both items are present insentry_items.Fixes #6449