fix(baggage): do not percent-encode W3C baggage metadata - #8682
Conversation
Neither the W3C Baggage spec nor the OTel baggage API require percent encoding of metadata (W3C properties). Encoding breaks property key-value shape for other implementations on extract/inject round-trips. Only baggage entry values remain percent-encoded/decoded. Fixes open-telemetry#6771
|
|
Pull request dashboard statusWaiting on reviewers · refreshed 2026-08-06 04:19 UTC Review the latest changes. Status above doesn't look right?
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8682 +/- ##
============================================
+ Coverage 91.48% 91.62% +0.13%
+ Complexity 10467 10327 -140
============================================
Files 1021 1003 -18
Lines 27694 27137 -557
Branches 3247 3188 -59
============================================
- Hits 25337 24864 -473
+ Misses 1615 1566 -49
+ Partials 742 707 -35 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jack-berg
left a comment
There was a problem hiding this comment.
Curios if @SergeyKanzhelev or @basti1302 can confirm my understanding based on your involvement in w3c/baggage#145
Address review: cite OTel opaque metadata + Propagation links, and note that W3C percent-encoding applies to list-member values and property *values* only — not to the entire OTel metadata blob as one unit.
|
Thanks @jack-berg — addressed both threads:
Comment-only follow-up: @SergeyKanzhelev @basti1302 — would appreciate a confirmation that this matches the #145 / #148 intent given OTel’s opaque metadata model. |
Description
Fixes #6771.
The W3C Baggage propagator was percent-encoding and percent-decoding metadata (W3C properties) on inject/extract. That is not required by either the W3C Baggage spec or the OTel baggage API (metadata is an opaque string). Encoding breaks property key-value shape for other implementations after an extract→inject round-trip, e.g.:
Change: leave metadata untouched on inject and extract. Baggage entry values continue to be percent-encoded/decoded as before (aligned with the W3C requirement for list-member values).
This matches the approach used by opentelemetry-js (opaque pass-through).
Testing
W3CBaggagePropagatorTest.injectexpectation (metadata not encoded)inject_doesNotPercentEncodeMetadataextract_metadataNotPercentDecodedroundTrip_metadataPreservedOpaque,(safe without encoding)Local:
All green on Temurin 21.0.12 (macOS aarch64).
Compatibility note
This is a deliberate behavior change for interop with W3C-compliant / JS implementations. Callers that relied on Java-side percent-encoding of metadata will see raw metadata strings on the wire and on extract. Values are unchanged.
CNCF CLA: may need human sign-off if the CLA bot requests it.