Skip to content

W3CBaggagePropagator: support multiple baggage headers in extract - #5814

Open
knowprasad wants to merge 2 commits into
open-telemetry:mainfrom
knowprasad:fix-5811-w3c-baggage-multiple-headers
Open

knowprasad wants to merge 2 commits into
open-telemetry:mainfrom
knowprasad:fix-5811-w3c-baggage-multiple-headers

Conversation

@knowprasad

@knowprasad knowprasad commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

In opentelemetry.baggage.propagation.W3CBaggagePropagator.extract, the implementation extracted only the first element from getter.get(carrier, self._BAGGAGE_HEADER_NAME). When a carrier contains multiple �aggage header entries (for example, when using frameworks that return a list of headers or when multiple integrations such as Sentry and OpenTelemetry inject separate baggage headers), all entries after the first were discarded.

Per the W3C Baggage specification:

A server receiving multiple Baggage header fields MUST combine them into a single list by appending each in field value order, separated by a comma (,).

And RFC 9110 Section 5.3:

A recipient MAY combine multiple field lines within each field section that have the same field name by appending each subsequent field line value to the combined value in order, separated by a comma and optional whitespace.

This PR updates W3CBaggagePropagator.extract to:

  1. Retrieve all header entries from getter.get(carrier, self._BAGGAGE_HEADER_NAME).
  2. Combine multiple header strings by joining with commas , in field value order.
  3. Add regression tests in est_w3cbaggagepropagator.py verifying multi-header extraction, comma-separated combinations, duplicate key handling (where later values win), and empty/whitespace entries.

Fixes #5811

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • Followed the style guidelines of this project
  • Changelog entry added to .changelog/5814.fixed
  • Added unit tests covering multiple baggage headers
  • Signed-off-by commit added (DCO)

…agator

Fixes open-telemetry#5811 by extracting all baggage header values returned by getter
instead of only the first element, combining multiple header fields
with commas in compliance with W3C Baggage and RFC 9110 specifications.

Signed-off-by: prsdx <prsdx.dev@gmail.com>
@knowprasad
knowprasad requested a review from a team as a code owner October 23, 2026 02:54
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on maintainers · refreshed 2026-10-26 20:57 UTC

Merge when ready.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Signed-off-by: prsdx <prsdx.dev@gmail.com>

@pmcollins pmcollins left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix.

BTW, might want to look into the (harmless) extraneous characters in the PR description and how they got there. Code looks good though.

@github-project-automation github-project-automation Bot moved this to Approved PRs in Python PR digest Oct 23, 2026
@herin049 herin049 added the hold label Oct 24, 2026
@herin049

Copy link
Copy Markdown
Contributor

Fyi, I've opened #5823 which bundles together a number of fixes (including this one), so we should probably hold off on this for now. The new PR also addresses a gap in this implementation which is that ",".join(...) performs a full redundant re-allocation of all of the Baggage header content.

@knowprasad

Copy link
Copy Markdown
Contributor Author

Thanks @pmcollins! Cleaned up the formatting in the PR description.

@herin049 thanks for linking #5823; happy to either land this targeted fix first or let #5823 supersede if maintainers prefer to merge the broader spec alignment as a single unit.

/dashboard route:reviewers

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

W3CBaggagePropagator.extract ignores all but the first baggage header

3 participants