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

Aperta Adatta ai principianti
#5,913 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@codedbyadiiii ci sta già lavorando.

Dal 10/11/2026.

  • #5915 di @codedbyadiiii — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
observability

Direzione di ricerca

Il limite per membro è la costante _MAX_PAIR_LENGTH, verificata sia nel percorso di extract sia in quello di inject di W3CBaggagePropagator; inizia leggendo dove viene usata questa costante e come ciascun percorso scarta un membro. Conferma la direzione proposta con un maintainer prima di modificare il codice, dato che l'interpretazione della specifica è la questione aperta. Aggiungi test di extract e inject a 4100 byte in tests/propagators/test_w3cbaggagepropagator.py e verifica che i limiti di 180 membri e 8192 byte continuino a valere.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Python
Stelle
2.7k
Fork
1.1k
Merge medio
4g 13m
PR unite (30g)
38

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di open-telemetry/opentelemetry-python

Tutte le issue di open-telemetry/opentelemetry-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.