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

Abierto Apto para principiantes
#5,913 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@codedbyadiiii ya está trabajando en esto.

Desde el 10/11/2026.

  • #5915 de @codedbyadiiii — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

El límite por miembro es la constante _MAX_PAIR_LENGTH, que se verifica tanto en la ruta de extract como en la de inject de W3CBaggagePropagator; empieza leyendo dónde se usa esa constante y cómo cada ruta descarta un miembro. Confirma la dirección propuesta con un maintainer antes de editar, ya que la interpretación de la especificación es la cuestión abierta. Añade pruebas de extract e inject con 4100 bytes en tests/propagators/test_w3cbaggagepropagator.py y comprueba que los límites de 180 miembros y 8192 bytes siguen cumpliéndose.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Python
Estrellas
2.7k
Forks
1.1k
Merge medio
4 d 13 min
PR fusionados (30 d)
38

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de open-telemetry/opentelemetry-python

Todos los issues de open-telemetry/opentelemetry-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.