Describe the bug
W3CBaggagePropagator does not extract baggage members with an empty value, for example baggage: key1=.
According to the W3C baggage grammar, value = *baggage-octet, so an empty value is valid. Java currently treats this as invalid and drops the entry.
Steps to reproduce
Extract baggage from a carrier containing:
For example, the current test behavior is:
Context result =
W3CBaggagePropagator.getInstance()
.extract(Context.root(), ImmutableMap.of("baggage", "key1="), getter);
assertThat(Baggage.fromContext(result)).isEqualTo(Baggage.empty());
What did you expect to see?
The extracted baggage should contain key1 with an empty string value:
Baggage.builder().put("key1", "").build()
What did you see instead?
The entry is dropped and extraction returns empty baggage.
What version and what artifacts are you using?
Artifacts: opentelemetry-api
Version: current main
How did you reference these artifacts? N/A
Environment
Compiler: N/A
OS: N/A
Runtime: N/A
OS, if different from OS compiled on: N/A
Additional context
This was found while reviewing open-telemetry/opentelemetry-dotnet#7376. with W3C baggage behavior across four OpenTelemetry implementations: .NET, Go, Java, and Rust.
The W3C baggage definition allows empty values:
list-member = key OWS "=" OWS value *( OWS ";" OWS property )
value = *baggage-octet
Because value is zero-or-more baggage-octet, key1= is valid.
The other reviewed implementations accept empty baggage values:
- OpenTelemetry .NET accepts
SomeKey=.
- OpenTelemetry Go accepts
key1=.
- OpenTelemetry Rust accepts
key1=.
Java appears to be the outlier by treating empty values as invalid.
Describe the bug
W3CBaggagePropagatordoes not extract baggage members with an empty value, for examplebaggage: key1=.According to the W3C baggage grammar,
value = *baggage-octet, so an empty value is valid. Java currently treats this as invalid and drops the entry.Steps to reproduce
Extract baggage from a carrier containing:
baggage: key1=For example, the current test behavior is:
What did you expect to see?
The extracted baggage should contain
key1with an empty string value:What did you see instead?
The entry is dropped and extraction returns empty baggage.
What version and what artifacts are you using?
Artifacts:
opentelemetry-apiVersion: current
mainHow did you reference these artifacts? N/A
Environment
Compiler: N/A
OS: N/A
Runtime: N/A
OS, if different from OS compiled on: N/A
Additional context
This was found while reviewing open-telemetry/opentelemetry-dotnet#7376. with W3C baggage behavior across four OpenTelemetry implementations: .NET, Go, Java, and Rust.
The W3C baggage definition allows empty values:
Because
valueis zero-or-morebaggage-octet,key1=is valid.The other reviewed implementations accept empty baggage values:
SomeKey=.key1=.key1=.Java appears to be the outlier by treating empty values as invalid.