Skip to content

Adds '+' character to allowed characters in baggage value - #4898

Merged
jack-berg merged 7 commits into
open-telemetry:mainfrom
lmonkiewicz:issue-4892
Nov 10, 2022
Merged

Adds '+' character to allowed characters in baggage value#4898
jack-berg merged 7 commits into
open-telemetry:mainfrom
lmonkiewicz:issue-4892

Conversation

@lmonkiewicz

Copy link
Copy Markdown
Contributor

This is a bit dirty way to fix it, but the alternative would be to rewrite from scratch URLDecoder, which treats + character as space. We can't use URLDecorder source code and modify it, since it is GPL licensed (at least that is how I understand it).

Maybe we could use some other implementation of URL Decoder that allows for greater customization, but nothing comes to my mind.

Fixes: #4892

@lmonkiewicz
lmonkiewicz requested a review from a team October 29, 2022 11:06
@codecov

codecov Bot commented Oct 29, 2022

Copy link
Copy Markdown

Codecov Report

Base: 90.90% // Head: 90.98% // Increases project coverage by +0.07% 🎉

Coverage data is based on head (992e63b) compared to base (51ff803).
Patch coverage: 85.71% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4898      +/-   ##
============================================
+ Coverage     90.90%   90.98%   +0.07%     
- Complexity     4803     4839      +36     
============================================
  Files           545      546       +1     
  Lines         14340    14439      +99     
  Branches       1383     1395      +12     
============================================
+ Hits          13036    13137     +101     
+ Misses          897      894       -3     
- Partials        407      408       +1     
Impacted Files Coverage Δ
.../opentelemetry/api/baggage/propagation/Parser.java 97.05% <66.66%> (+1.47%) ⬆️
...elemetry/api/baggage/propagation/BaggageCodec.java 88.88% <88.88%> (ø)
...gator/DoubleExplicitBucketHistogramAggregator.java 95.71% <0.00%> (-4.29%) ⬇️
...metry/sdk/metrics/export/PeriodicMetricReader.java 87.14% <0.00%> (-2.86%) ⬇️
...va/io/opentelemetry/sdk/logs/SdkLoggerBuilder.java 100.00% <0.00%> (ø)
...a/io/opentelemetry/sdk/logs/SdkLoggerProvider.java 100.00% <0.00%> (ø)
.../io/opentelemetry/sdk/logs/LogRecordProcessor.java 85.71% <0.00%> (ø)
...a/io/opentelemetry/sdk/trace/SdkTracerBuilder.java 100.00% <0.00%> (ø)
.../io/opentelemetry/sdk/metrics/SdkMeterBuilder.java 100.00% <0.00%> (ø)
...opentelemetry/sdk/logs/NoopLogRecordProcessor.java 100.00% <0.00%> (ø)
... and 9 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jack-berg

Copy link
Copy Markdown
Member

Maybe we could use some other implementation of URL Decoder that allows for greater customization, but nothing comes to my mind.

Your interpretation is correct.

I also wondered if there is any performance benefit in checking for the presence of + before doing the replace, but this discussion indicates that the performance is improving over time, so implementation should eventually include any possible optimizations.

I think its either this approach or vendoring in some other url decoder like apache URLCodec.

@jack-berg jack-berg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. Just a couple of minor cleanups.

Comment thread api/all/src/main/java/io/opentelemetry/api/baggage/propagation/BaggageCodec.java Outdated
Comment thread api/all/src/main/java/io/opentelemetry/api/baggage/propagation/BaggageCodec.java Outdated
Comment thread api/all/src/main/java/io/opentelemetry/api/baggage/propagation/BaggageCodec.java Outdated
Comment thread api/all/src/main/java/io/opentelemetry/api/baggage/propagation/BaggageCodec.java Outdated
* @return decoded value
*/
@Nullable
static String decode(@Nullable String value, Charset charset) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like value is never null. Can remove the @Nullable annotation on the value argument, and also maybe on the response. That should improve test coverage.

Same recommendation applies to private static byte[] decode(@Nullable byte[] bytes) above.

@jack-berg jack-berg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the one last comment about @Nullable. Thanks!

@jkwatson jkwatson changed the title Adds '+' character to allowed characters in baggade value Adds '+' character to allowed characters in baggage value Nov 10, 2022
@jack-berg
jack-berg merged commit e814602 into open-telemetry:main Nov 10, 2022
dmarkwat pushed a commit to dmarkwat/opentelemetry-java that referenced this pull request Dec 30, 2022
…etry#4898)

* Adds '+' character to allowed characters in baggade value

* Formatting fix

* Adda BaggageCodec implementation

* Additional cleanup

* Removal of Nullable method parameters.

* Additional tests for baggage decoding
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.

baggage header decoding corrupts base64 format

4 participants