Skip to content

Add max baggage length as limitation#8222

Open
XSAM wants to merge 31 commits into
open-telemetry:mainfrom
XSAM:fix/baggage-parsing
Open

Add max baggage length as limitation#8222
XSAM wants to merge 31 commits into
open-telemetry:mainfrom
XSAM:fix/baggage-parsing

Conversation

@XSAM
Copy link
Copy Markdown
Member

@XSAM XSAM commented Apr 17, 2026

goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/baggage
cpu: Apple M1 Max
                  │      old.txt      │               new.txt                │
                  │      sec/op       │   sec/op     vs base                 │
ParseOversized-10   23409245.5n ± 14%   133.2n ± 3%  -100.00% (p=0.000 n=10)

                  │    old.txt     │              new.txt               │
                  │      B/op      │    B/op     vs base                │
ParseOversized-10   801099.00 ± 0%   88.00 ± 0%  -99.99% (p=0.000 n=10)

                  │     old.txt     │               new.txt               │
                  │    allocs/op    │ allocs/op   vs base                 │
ParseOversized-10   250007.000 ± 0%   3.000 ± 0%  -100.00% (p=0.000 n=10)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.9%. Comparing base (effbbb2) to head (84bb8b4).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8222   +/-   ##
=====================================
  Coverage   82.9%   82.9%           
=====================================
  Files        314     314           
  Lines      24998   25024   +26     
=====================================
+ Hits       20745   20768   +23     
- Misses      3881    3882    +1     
- Partials     372     374    +2     
Files with missing lines Coverage Δ
baggage/baggage.go 98.7% <100.0%> (-0.8%) ⬇️
propagation/baggage.go 96.6% <100.0%> (+1.6%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@XSAM XSAM marked this pull request as draft April 17, 2026 00:21
@XSAM XSAM marked this pull request as ready for review April 17, 2026 06:23
@pellared pellared requested a review from Copilot April 17, 2026 07:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds stricter enforcement of W3C Baggage size limits across parsing (baggage) and extraction (propagation), and reduces overhead/error verbosity for malformed inputs.

Changes:

  • Enforce an 8192-byte maximum baggage string size in baggage.Parse, and cap joined parse errors to a fixed maximum.
  • Add an aggregate byte budget guard when extracting from multiple baggage header values in the propagator.
  • Update/add tests and a benchmark to cover oversized inputs and aggregate-budget behavior, plus a changelog entry.

Reviewed changes

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

Show a summary per file
File Description
propagation/baggage.go Adds aggregate byte budget limit when processing multiple baggage header values.
propagation/baggage_test.go Updates expectations for aggregate-budget behavior and adds new extraction tests.
baggage/baggage.go Adds max-size early rejection and caps how many parse errors are joined.
baggage/baggage_test.go Updates parse tests for new oversize behavior; adds benchmark and error-cap test.
CHANGELOG.md Adds a release note about the baggage parsing/extraction change.

Comment thread baggage/baggage.go
Comment thread propagation/baggage_test.go
Comment thread CHANGELOG.md Outdated
Comment thread propagation/baggage.go Outdated
Comment thread propagation/baggage.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread propagation/baggage.go Outdated
Comment thread propagation/baggage.go Outdated
Comment thread baggage/baggage.go Outdated
Copy link
Copy Markdown
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

Thanks for tightening the aggregate-size handling here. I think there is one edge case left around repeated baggage headers where the combined wire value can still exceed the intended limit. I left an inline note on the specific check with the concrete case and the adjustment that should make the enforcement consistent.

Comment thread propagation/baggage.go
Comment thread propagation/baggage.go Outdated
@MrAlias MrAlias added this to the v1.44.0 milestone Apr 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread propagation/baggage.go
Comment thread propagation/baggage_test.go Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread CHANGELOG.md Outdated
@pellared
Copy link
Copy Markdown
Member

pellared commented Apr 29, 2026

Can you add both benchmark and benchstat results to the PR description?

Comment thread baggage/baggage_test.go Outdated
Comment thread propagation/baggage.go Outdated
Comment thread propagation/baggage.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread propagation/baggage.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comment thread propagation/baggage.go Outdated
Comment thread propagation/baggage.go
Comment thread baggage/baggage.go Outdated
Comment thread baggage/baggage.go
Comment thread propagation/baggage.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread propagation/baggage.go
Comment thread propagation/baggage_test.go
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.

5 participants