Describe the bug
OtTracePropagator.extract() creates a baggage entry with an empty string key when the carrier contains a header named exactly ot-baggage- (the prefix with no key after it).
Steps to reproduce
Extract from a carrier holding a valid OT span context plus a header keyed ot-baggage-:
Map<String, String> carrier = new LinkedHashMap<>();
carrier.put("ot-tracer-traceid", "ff000000000000000000000000000041");
carrier.put("ot-tracer-spanid", "ff00000000000041");
carrier.put("ot-tracer-sampled", "1");
carrier.put("ot-baggage-", "value");
Baggage baggage =
Baggage.fromContext(
OtTracePropagator.getInstance().extract(Context.current(), carrier, getter));
// baggage is {=ImmutableEntry{value=value, ...}} — expected Baggage.empty()
What did you expect to see?
Baggage.empty(). The sibling JaegerPropagator.getBaggageFromHeader() skips a header that is only the uberctx- prefix, and JaegerPropagatorTest.extract_baggageOnly_withPrefix_emptyKey asserts that contract. W3CBaggagePropagator.isValidBaggageKey() also treats an empty key as invalid.
What did you see instead?
A baggage entry keyed "". OtTracePropagator.extract() line 149 only checks startsWith, so substring at line 156 yields "" and line 161 puts it. The ImmutableKeyValuePairs Javadoc makes removing empty keys the caller's responsibility. A later inject() re-emits the entry, so it keeps propagating and consumes the 64-entry budget.
What version and what artifacts are you using?
Artifacts: opentelemetry-extension-trace-propagators
Version: main @ b86f040
How did you reference these artifacts? implementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
Environment
Compiler: Temurin 21
OS: N/A
Additional context
N/A
Describe the bug
OtTracePropagator.extract()creates a baggage entry with an empty string key when the carrier contains a header named exactlyot-baggage-(the prefix with no key after it).Steps to reproduce
Extract from a carrier holding a valid OT span context plus a header keyed
ot-baggage-:What did you expect to see?
Baggage.empty(). The siblingJaegerPropagator.getBaggageFromHeader()skips a header that is only theuberctx-prefix, andJaegerPropagatorTest.extract_baggageOnly_withPrefix_emptyKeyasserts that contract.W3CBaggagePropagator.isValidBaggageKey()also treats an empty key as invalid.What did you see instead?
A baggage entry keyed
"".OtTracePropagator.extract()line 149 only checksstartsWith, sosubstringat line 156 yields""and line 161 puts it. TheImmutableKeyValuePairsJavadoc makes removing empty keys the caller's responsibility. A laterinject()re-emits the entry, so it keeps propagating and consumes the 64-entry budget.What version and what artifacts are you using?
Artifacts: opentelemetry-extension-trace-propagators
Version: main @ b86f040
How did you reference these artifacts?
implementation("io.opentelemetry:opentelemetry-extension-trace-propagators")Environment
Compiler: Temurin 21
OS: N/A
Additional context
N/A