Fix/baggage propagator outbound limits#5163
Merged
lzchen merged 12 commits intoopen-telemetry:mainfrom May 5, 2026
Merged
Conversation
Assisted-by: Claude Opus 4.6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude Opus 4.6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The _apply_baggage_limits helper already logs a warning when the maximum number of list-members is exceeded, making the early check redundant. Assisted-by: Claude Opus 4.6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ocelotl
reviewed
Apr 30, 2026
ocelotl
reviewed
Apr 30, 2026
ocelotl
reviewed
Apr 30, 2026
ocelotl
reviewed
Apr 30, 2026
Contributor
ocelotl
left a comment
There was a problem hiding this comment.
Just a few comments/questions ✌️
herin049
reviewed
Apr 30, 2026
herin049
reviewed
Apr 30, 2026
There was a problem hiding this comment.
Pull request overview
This PR enforces W3C Baggage outbound size limits in W3CBaggagePropagator.inject() and refactors limit enforcement into a shared helper used by both extraction and injection to consistently cap header size, pair size, and number of members.
Changes:
- Add shared
_apply_baggage_limits()helper and use it in bothextract()andinject(). - Enforce outbound inject limits (max pairs, max list-member length, max header length) and avoid injecting an empty baggage header when everything is dropped.
- Update/add tests and document the behavior change in the changelog (extract counting behavior).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| opentelemetry-api/src/opentelemetry/baggage/propagation/init.py | Adds shared size-limit helper; applies limits in extract() and inject(); refactors encoding helper. |
| opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py | Updates extraction log expectations; adds new injection limit tests; adjusts fields test mocking. |
| opentelemetry-api/tests/propagators/test__envcarrier.py | Updates fields test mocking to align with new injection implementation. |
| CHANGELOG.md | Notes outbound enforcement and extract counting behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…__.py Co-authored-by: Lukas Hering <40302054+herin049@users.noreply.github.com>
…y-python into fix/baggage-propagator-outbound-limits
Enforce header value and total size limits when injecting baggage entries per the W3C Baggage specification. Assisted-by: Claude Opus 4.6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude Opus 4.6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
herin049
approved these changes
Apr 30, 2026
Assisted-by: Claude Opus 4.6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
aabmass
approved these changes
May 4, 2026
DylanRussell
reviewed
May 5, 2026
DylanRussell
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Address size limits for inject outbound calls in baggage. I refactored out length + validation logic out since we are using it for both extract and inject now. One behavioral breaking change is that previously, only VALID entries in extract counted towards the 180 limit but I believe we should count ALL entries so attackers won't be able to fill the header with a bunch of invalid entries. The spec is unclear about this.