Skip to content

fix(baggage): do not percent-encode W3C baggage metadata - #8682

Open
arimu1 wants to merge 1 commit into
open-telemetry:mainfrom
arimu1:fix/6771-baggage-metadata-no-percent-encode
Open

fix(baggage): do not percent-encode W3C baggage metadata#8682
arimu1 wants to merge 1 commit into
open-telemetry:mainfrom
arimu1:fix/6771-baggage-metadata-no-percent-encode

Conversation

@arimu1

@arimu1 arimu1 commented Aug 1, 2026

Copy link
Copy Markdown

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.:

SomeKey=SomeValue;ValueProp \t = \t PropVal
→ SomeKey=SomeValue;ValueProp%20%09%20%3D%20%09%20PropVal

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

  • Updated W3CBaggagePropagatorTest.inject expectation (metadata not encoded)
  • Added regression tests for W3C Baggage Propagator should not percent-encode metadata #6771:
    • inject_doesNotPercentEncodeMetadata
    • extract_metadataNotPercentDecoded
    • roundTrip_metadataPreservedOpaque
  • Invalid percent sequences in metadata no longer drop the member (only invalid value encoding does)
  • Fuzz tests: metadata generator excludes list separator , (safe without encoding)

Local:

./gradlew :api:all:test \
  --tests 'io.opentelemetry.api.baggage.propagation.W3CBaggagePropagatorTest' \
  --tests 'io.opentelemetry.api.baggage.propagation.W3CBaggagePropagatorFuzzTest' \
  --tests 'io.opentelemetry.api.baggage.propagation.BaggageCodecTest'

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.

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
@arimu1
arimu1 requested a review from a team as a code owner August 1, 2026 04:09
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 1, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: arimu1 / name: arimu1 (fb8a048)

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 1, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-08-01 05:43 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.

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.48%. Comparing base (f8bd413) to head (fb8a048).

Files with missing lines Patch % Lines
.../api/baggage/propagation/W3CBaggagePropagator.java 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8682      +/-   ##
============================================
- Coverage     91.48%   91.48%   -0.01%     
  Complexity    10467    10467              
============================================
  Files          1021     1021              
  Lines         27694    27691       -3     
  Branches       3247     3247              
============================================
- Hits          25337    25333       -4     
- Misses         1615     1616       +1     
  Partials        742      742              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

W3C Baggage Propagator should not percent-encode metadata

1 participant