Title: Baggage.serialize(include_third_party=True) leaves a trailing comma when there are no third-party items · Issue #8120 · getsentry/sentry-python · GitHub
Open Graph Title: Baggage.serialize(include_third_party=True) leaves a trailing comma when there are no third-party items · Issue #8120 · getsentry/sentry-python
X Title: Baggage.serialize(include_third_party=True) leaves a trailing comma when there are no third-party items · Issue #8120 · getsentry/sentry-python
Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.73.0 (current master) Steps to Reproduce Baggage.serialize(include_third_party=True) in sentry_sdk/tracing_utils.py appends self.third_party_items unconditionally. When there are n...
Open Graph Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.73.0 (current master) Steps to Reproduce Baggage.serialize(include_third_party=True) in sentry_sdk/tracing_utils.py appends self.third_party...
X Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.73.0 (current master) Steps to Reproduce Baggage.serialize(include_third_party=True) in sentry_sdk/tracing_utils.py appends self.third_party...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/8120
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Baggage.serialize(include_third_party=True) leaves a trailing comma when there are no third-party items","articleBody":"### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Version\n\n2.73.0 (current master)\n\n### Steps to Reproduce\n\n`Baggage.serialize(include_third_party=True)` in `sentry_sdk/tracing_utils.py` appends `self.third_party_items` unconditionally. When there are no third-party items it is `\"\"`, so `\",\".join(items)` ends with an empty member.\n\n```python\nfrom sentry_sdk.tracing_utils import Baggage\n\nbaggage = Baggage({\"trace_id\": \"771a43a4192642f0b136d5159a501700\", \"sample_rate\": \"0.5\"})\nprint(baggage.serialize(include_third_party=True))\n```\n\nThis is reachable from the Celery integration: `_update_celery_task_headers` calls `combined.serialize(include_third_party=True)` when it merges incoming and Sentry baggage, so the common Sentry -> Celery -> Sentry case (incoming baggage with only `sentry-` items) sends the outgoing `baggage` header with the stray comma.\n\n### Expected Result\n\nNo trailing comma when there are no third-party items:\n\n```\nsentry-trace_id=771a43a4192642f0b136d5159a501700,sentry-sample_rate=0.5\n```\n\nThe output with third-party items present stays as it is today.\n\n### Actual Result\n\n```\nsentry-trace_id=771a43a4192642f0b136d5159a501700,sentry-sample_rate=0.5,\n```\n\nUnder the W3C Baggage spec the trailing comma is an empty list-member. Sentry's own parser tolerates it, but a strict W3C / OpenTelemetry baggage parser on a downstream service can reject or mishandle the header.\n\nProposed fix: only append `third_party_items` when it is non-empty (`if include_third_party and self.third_party_items:`). I have this ready with a test in #8119 and am happy to adjust the approach.","author":{"url":"https://github.com/alphasafal","@type":"Person","name":"alphasafal"},"datePublished":"2026-10-26T02:09:39Z","url":"https://github.com/getsentry/sentry-python/issues/8120"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:56923661-3458-eb04-b600-faed3c804607 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9FF6:3CB8BE:2B00DE:3BEF0E:6B008937 |
| html-safe-nonce | 6a979a55c0e8f1cd483a71a401474b0289ff5702db3aed6555fcf5e0f1210ab6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkY2OjNDQjhCRToyQjAwREU6M0JFRjBFOjZCMDA4OTM3IiwidmlzaXRvcl9pZCI6IjM2MzQ5NjY3MzAwNTAxNDQ1NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1b555e471cd0e0efcdd2b962fe6932a98ba9592b10275be7435ed0db0cda19fd |
| hovercard-subject-tag | issue:6032044574 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/8120/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4cbd235b02c8aa32171b8507022c148eae469cb4f2e05d0ae02269cc6256e68a/getsentry/sentry-python/issues/8120 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4cbd235b02c8aa32171b8507022c148eae469cb4f2e05d0ae02269cc6256e68a/getsentry/sentry-python/issues/8120 |
| og:image:alt | How do you use Sentry? Sentry Saas (sentry.io) Version 2.73.0 (current master) Steps to Reproduce Baggage.serialize(include_third_party=True) in sentry_sdk/tracing_utils.py appends self.third_party... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alphasafal |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4d3d8e50f02c1d7bf86d5acfa1d3bfe9366abd6528a6b429eb07a168429d2b61 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | db758f8e02b8257935fb03edf81a3e76eb3abd11 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width