Skip to content

Fix W3CPropagator baggage parsing after malformed entries - #129287

Merged
tarekgh merged 2 commits into
dotnet:mainfrom
Kielek:w3cpropagator-do-not-break
Jun 11, 2026
Merged

tarekgh merged 2 commits into
dotnet:mainfrom
Kielek:w3cpropagator-do-not-break

Conversation

@Kielek

@Kielek Kielek commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #129286
Whole description in the linked issues.

Copilot AI review requested due to automatic review settings June 11, 2026 13:32
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jun 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates W3C baggage parsing to be more resilient by skipping malformed entries instead of failing the entire header, and adds tests to validate the new behavior.

Changes:

  • Add coverage ensuring malformed baggage list items don’t prevent decoding of subsequent valid items.
  • Update TryExtractBaggage loop to continue on malformed entries rather than break.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/libraries/System.Diagnostics.DiagnosticSource/tests/W3CPropagatorTests.cs Adds tests asserting malformed baggage entries are skipped and valid entries still decode.
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/W3CPropagator.cs Changes baggage parsing to advance past malformed items instead of aborting parsing.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @dotnet/area-system-diagnostics-tracing
See info in area-owners.md if you want to be subscribed.

@tarekgh

tarekgh commented Jun 11, 2026

Copy link
Copy Markdown
Member

Although the spec leaving it to the system to decide if continue parsing or ignore the whole baggage-string, I agree it is better to ignore only the malformed entry and continue parsing (as other SDKs do).

https://github.com/w3c/baggage/blob/main/baggage/HTTP_HEADER_FORMAT.md#mutating-baggage

If a system determines that the value of baggage-string is not in the format defined in this specification, the behavior is undefined. For example, it MAY remove an offending list-member before propagating the rest of the baggage-string, or MAY decide to not propagate the baggage-string at all. This specification is not specifying how implementation may decide which list-members may be considered correct when the whole string is not a correct baggage-string as the specification does not prescribe any particular parsing algorithm

CC @noahfalk

@tarekgh tarekgh 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.

Thanks @Kielek for providing the change.

@tarekgh tarekgh added this to the 11.0.0 milestone Jun 11, 2026
@tarekgh
tarekgh merged commit bfcf5c2 into dotnet:main Jun 11, 2026
95 checks passed
@Kielek
Kielek deleted the w3cpropagator-do-not-break branch June 11, 2026 18:02
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview6 Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Diagnostics.Tracing community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

W3CPropagator stops parsing baggage after malformed member instead of continuing with later valid members

3 participants