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

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/5811.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 reviewers · refreshed 2026-10-23 04:00 UTC

Review the latest changes.

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>

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

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

W3CBaggagePropagator.extract ignores all but the first baggage header

1 participant