W3CBaggagePropagator drops a list-member over 4096 bytes that W3C Baggage requires it to propagate

オープン 初心者向け
#5,913 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@codedbyadiiii がすでに取り組んでいます。

2026年11月10日 から。

  • #5915 @codedbyadiiii による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
observability

調査の方向性

メンバーごとの上限は定数 _MAX_PAIR_LENGTH で、W3CBaggagePropagator の extract パスと inject パスの両方でチェックされます。まずこの定数がどこで使われているか、そして各パスがどのようにメンバーを破棄するかを読んでください。仕様の解釈が未解決の論点なので、編集する前にメンテナーと提案の方向性を確認してください。tests/propagators/test_w3cbaggagepropagator.py に 4100 バイトの extract と inject のテストを追加し、180 メンバーと 8192 バイトの上限が引き続き成り立つことを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Describe your environment
  • OS: macOS 26.7.2
  • Python version: Python 3.15.2
  • SDK version: main at 66ec883
  • API version: main at 66ec883
What happened?

W3CBaggagePropagator drops any list-member longer than 4096 bytes (_MAX_PAIR_LENGTH), on extract and on inject, even when the whole header is far below 8192 bytes. W3C Baggage has no per-member limit. Its Limits section says a platform MUST propagate all list-members while the baggage-string has 64 members or fewer and is 8192 bytes or smaller, and only past that MAY it drop some.

Steps to Reproduce
from opentelemetry import baggage
from opentelemetry.baggage.propagation import W3CBaggagePropagator

p = W3CBaggagePropagator()
header = "session=" + "a" * 4092 + ",user=alice"   # 2 members, 4112 bytes
print("extract:", {k: len(v) for k, v in baggage.get_all(p.extract({"baggage": header})).items()})
carrier = {}
p.inject(carrier, baggage.set_baggage("session", "a" * 4092))   # 1 member, 4100 bytes
print("inject:", carrier)
Expected Result
extract: {'session': 4092, 'user': 5}
inject: {'baggage': 'session=aaaa...'}
Actual Result
$ python bag.py
Baggage entry with key `session` exceeded the maximum number of bytes per list-member with length 4100
Baggage entry with key `session` exceeded the maximum number of bytes per list-member with length 4100
extract: {'user': 5}
inject: {}
Additional context

With _MAX_PAIR_LENGTH = 8192 the same script prints the expected result, and tests/propagators/test_w3cbaggagepropagator.py still passes (34 passed), because its tests derive their sizes from the constant. The 4096 comes from the 2020 Working Draft ("Maximum number of bytes per a single name-value pair: 4096"), which #5163 followed on inject; the current text dropped it, and #5823 kept it. opentelemetry-go has no per-member limit, and its larger members vanish at the first Python hop.

My pick is to remove the per-member check and keep the 180-member and 8192-byte limits. Shall I send that as a pull request with an extract and an inject test at 4100 bytes?

Would you like to implement a fix?

Yes

主要言語
Python
スター
2.7k
フォーク
1.1k
平均マージ
4日 13分
マージ済み PR(30日)
38

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

open-telemetry/opentelemetry-python のほかの issue

open-telemetry/opentelemetry-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。