Fix W3CBaggagePropagator to allow empty baggage values per W3C spec#8468
Conversation
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8468 +/- ##
============================================
+ Coverage 91.00% 91.54% +0.54%
- Complexity 7817 10261 +2444
============================================
Files 893 1013 +120
Lines 23721 27106 +3385
Branches 2364 3183 +819
============================================
+ Hits 21588 24815 +3227
- Misses 1410 1565 +155
- Partials 723 726 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| private final BitSet excluded; | ||
| private boolean allowEmpty; | ||
| private boolean seenWhitespace; |
There was a problem hiding this comment.
There was a problem hiding this comment.
this is still not addressed. You can remove this entire seenWhitespace variable and related code branches, and then the extract_value_onlySpaces test needs to be updated to:
@Test
void extract_value_onlySpaces() {
W3CBaggagePropagator propagator = W3CBaggagePropagator.getInstance();
Context result =
propagator.extract(Context.root(), ImmutableMap.of("baggage", "key1= "), getter);
Baggage expectedBaggage =
Baggage.builder().put("key1", "").build();
assertThat(Baggage.fromContext(result)).isEqualTo(expectedBaggage);
}There was a problem hiding this comment.
Applied in 18eea53. Thanks for the example PR!
|
This PR has review comments. Review suggestions, whether from maintainers or automated reviewers, aren't always correct or required. Please evaluate each comment on its merits, then make sure each thread has a clear outcome. For example, link to the commit if you applied a suggestion, explain why it wasn't applied, or ask a follow-up question. Automation flags a PR for human review once every review thread has a reply or is marked as resolved. Status across open PRs is visible on the pull request dashboard. |
Fixes #8465
W3CBaggagePropagatordrops baggage entries with empty values likekey1=, but the W3C spec definesvalue = *baggage-octet, meaning zero characters is valid..NET, Go, and Rust implementations already accept empty values — Java was the only outlier.
Changes
allowEmptyflag toElement.createValueElement()to permit empty string valuesseenWhitespacetracking to distinguishkey=(valid) fromkey=(invalid)