opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

[baggage] fix encoding of space chars in baggage item value

Open lachmatt opened this issue 1 year ago • 2 comments

Fixes #5260

Changes

Fixes encoding of ' ' char in baggage item values when injecting baggage. Spaces should be percent-encoded, instead of being converted to '+' character.

Note

Some characters not required to be percent-encoded by the W3C baggage specification are percent-encoded, which results in longer representation. This might be important considering baggage limits.

Alternative:

Custom encoder, which escapes only characters required by the W3C baggage specification. Draft in https://github.com/open-telemetry/opentelemetry-dotnet/pull/5292

Merge requirement checklist

  • [x] CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • [x] Unit tests added/updated
  • [ ] Appropriate CHANGELOG.md files updated for non-trivial changes
  • [ ] Changes in public API reviewed (if applicable)

lachmatt avatar Feb 01 '24 12:02 lachmatt

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.58%. Comparing base (6250307) to head (8046eaa). Report is 167 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5303      +/-   ##
==========================================
+ Coverage   83.38%   85.58%   +2.19%     
==========================================
  Files         297      289       -8     
  Lines       12531    12588      +57     
==========================================
+ Hits        10449    10773     +324     
+ Misses       2082     1815     -267     
Flag Coverage Δ
unittests ?
unittests-Solution-Experimental 85.56% <100.00%> (?)
unittests-Solution-Stable 85.49% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...metry.Api/Context/Propagation/BaggagePropagator.cs 85.48% <100.00%> (ø)

... and 63 files with indirect coverage changes

codecov[bot] avatar Feb 01 '24 12:02 codecov[bot]

@lachmatt I missed something earlier - I think this would cause an issue due to difference in versions. https://learn.microsoft.com/en-us/dotnet/api/system.uri.unescapedatastring?view=net-8.0#remarks

Consider a service using old sdk injecting baggage and receiving side service(incoming request) updates to this change. it would cause issues with space decoding.

vishweshbankwar avatar Feb 07 '24 17:02 vishweshbankwar

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

github-actions[bot] avatar Feb 15 '24 03:02 github-actions[bot]

@lachmatt I missed something earlier - I think this would cause an issue due to difference in versions. https://learn.microsoft.com/en-us/dotnet/api/system.uri.unescapedatastring?view=net-8.0#remarks

Consider a service using old sdk injecting baggage and receiving side service(incoming request) updates to this change. it would cause issues with space decoding.

@vishweshbankwar That's a valid concern, but I don't see a good solution for it. On the one hand, you might have service using old sdk injecting baggage, where + actually encodes space, on the other there are other, spec-compliant implementations (e.g from other languages), where + encodes +.

lachmatt avatar Feb 23 '24 12:02 lachmatt

@lachmatt I missed something earlier - I think this would cause an issue due to difference in versions. https://learn.microsoft.com/en-us/dotnet/api/system.uri.unescapedatastring?view=net-8.0#remarks

Consider a service using old sdk injecting baggage and receiving side service(incoming request) updates to this change. it would cause issues with space decoding.

True. This is just another reason that this should be fixed. Other (compliant with the specification e.g. from other languages) implementations will encode + as +. It is not possible to have decoding that would support both the buggy encoding and spec-complaint encoding.

pellared avatar Feb 23 '24 13:02 pellared

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

github-actions[bot] avatar Mar 02 '24 03:03 github-actions[bot]

@open-telemetry/dotnet-maintainers This bug makes the baggage propagation not working properly with other SDKs.

pellared avatar Mar 06 '24 09:03 pellared

@open-telemetry/dotnet-maintainers This bug makes the baggage propagation not working properly with other SDKs.

@lachmatt \ @pellared - Sorry for the delay on this. I do have some questions on the spec. I will reach out to you offline to get the clarification. Thanks for your patience.

vishweshbankwar avatar Mar 13 '24 22:03 vishweshbankwar

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

github-actions[bot] avatar Mar 21 '24 03:03 github-actions[bot]

@open-telemetry/dotnet-approvers PTAL. We would like to have it fixed at least for 1.8.0.

pellared avatar Mar 27 '24 15:03 pellared

@lachmatt - please add the changelog as well.

vishweshbankwar avatar Apr 04 '24 19:04 vishweshbankwar

@lachmatt - please add the changelog as well.

Yes I think we should mention this in CHANGELOG and note that is it potentially a breaking change.

CodeBlanch avatar Apr 04 '24 20:04 CodeBlanch