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

Offen Anfängerfreundlich
#5,913 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@codedbyadiiii arbeitet bereits daran.

Seit 10.11.2026.

  • #5915 von @codedbyadiiii — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
70/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
observability

Rechercherichtung

Das Limit pro Mitglied ist die Konstante _MAX_PAIR_LENGTH, die sowohl im Extract- als auch im Inject-Pfad von W3CBaggagePropagator geprüft wird. Beginne damit zu lesen, wo diese Konstante verwendet wird und wie jeder Pfad ein Mitglied verwirft. Bestätige die vorgeschlagene Richtung mit einem Maintainer, bevor du etwas änderst, da die Lesart der Spezifikation die offene Frage ist. Füge Extract- und Inject-Tests mit 4100 Bytes in tests/propagators/test_w3cbaggagepropagator.py hinzu und prüfe, dass die Limits von 180 Mitgliedern und 8192 Bytes weiterhin gelten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
Python
Sterne
2.7k
Forks
1.1k
Ø Merge
4 T. 13 Min.
Gemergte PRs (30 T.)
38

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus open-telemetry/opentelemetry-python

Alle Issues in open-telemetry/opentelemetry-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.