Skip to content

Expand test coverage for Baggage Encoding#6919

Open
VanshikaNavya wants to merge 6 commits intoopen-telemetry:mainfrom
VanshikaNavya:Expand-test-coverage-for-baggage-encoding
Open

Expand test coverage for Baggage Encoding#6919
VanshikaNavya wants to merge 6 commits intoopen-telemetry:mainfrom
VanshikaNavya:Expand-test-coverage-for-baggage-encoding

Conversation

@VanshikaNavya
Copy link
Contributor

@VanshikaNavya VanshikaNavya commented Feb 23, 2026

Contributes to #5500

Changes

Added 7 extraction tests covering multiple = handling, empty value skipping, OWS parsing, semicolon metadata ignoring, percent decoding, invalid format skipping, and complex percent-encoded character decoding, and 6 injection tests covering 64 entry limit, 8192 byte limit, max size enforcement across many entries, round trip preservation, multiple = value preservation, and special character encoding behavior, with current spec mismatches marked as skipped.

Merge requirement checklist

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

@github-actions github-actions bot added the pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package label Feb 23, 2026
@cijothomas
Copy link
Member

@VanshikaNavya I left a comment on the issue just now about whether this component has long term need or not. Irrespective, this additional tests are good.

As an extra step, I also wonder if these should be replicated to the Baggage propagator code in the .NET runtime repo itself. @xiang17 might know as he has already fixed some issues in the .NET runtime repo about W3C propagators long ago.

@VanshikaNavya
Copy link
Contributor Author

@VanshikaNavya I left a comment on the issue just now about whether this component has long term need or not. Irrespective, this additional tests are good.

As an extra step, I also wonder if these should be replicated to the Baggage propagator code in the .NET runtime repo itself. @xiang17 might know as he has already fixed some issues in the .NET runtime repo about W3C propagators long ago.

@cijothomas Thanks for raising that. I’m honestly not sure whether these tests should also be replicated in the .NET runtime repository.

My current goal is to align the OpenTelemetry baggage propagator behavior with the W3C spec test cases (https://github.com/w3c/baggage/blob/main/test/test_baggage.py), as mentioned in the issue.

Some of these tests are currently failing. For example, cases where values after ; are not being ignored as expected by the spec. Should I include the corresponding fixes in this PR to make the implementation fully spec-compliant, or would you prefer handling that separately?

@xiang17 if the Baggage implementation in the .NET runtime is also expected to strictly follow the W3C baggage parsing rules, should similar tests be added there as well? And if so, would that require a separate PR in dotnet/runtime?

@VanshikaNavya
Copy link
Contributor Author

VanshikaNavya commented Feb 25, 2026

@cijothomas @Kielek @martincostello I have added 13 test cases with reference to https://github.com/w3c/baggage/blob/main/test/test_baggage.py as mentioned in the issue.

Out of these, 3 tests are currently failing due to differences from the spec behavior.

The three failing tests are:

  • ValidateOWSOnExtraction, where optional whitespace around keys and values is not being trimmed as expected by the spec.
  • ValidateSemicolonMetadataIgnoredOnExtraction, where metadata after ; is not currently being ignored during extraction.
  • ValidateSpecialCharactersInjection, where spaces are not being percent-encoded during injection as required by the spec. This test passes with '+'.

I have marked them as skipped for now.
Would you like me to address those fixes as part of this PR?

@VanshikaNavya VanshikaNavya marked this pull request as ready for review February 25, 2026 15:46
@VanshikaNavya VanshikaNavya requested a review from a team as a code owner February 25, 2026 15:46
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.45%. Comparing base (3487b5a) to head (3b08d52).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6919      +/-   ##
==========================================
- Coverage   88.54%   88.45%   -0.09%     
==========================================
  Files         263      263              
  Lines       12383    12383              
==========================================
- Hits        10964    10954      -10     
- Misses       1419     1429      +10     
Flag Coverage Δ
unittests-Project-Experimental 88.38% <ø> (+0.10%) ⬆️
unittests-Project-Stable 88.32% <ø> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 3 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants