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

Aberta Para iniciantes
#5,913 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

@codedbyadiiii já está trabalhando nisso.

Desde 10/11/2026.

  • #5915 de @codedbyadiiii — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
70/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
observability

Direção de pesquisa

O limite por membro é a constante _MAX_PAIR_LENGTH, verificada tanto no caminho de extract quanto no de inject de W3CBaggagePropagator; comece lendo onde essa constante é usada e como cada caminho descarta um membro. Confirme a direção proposta com um maintainer antes de editar, já que a interpretação da especificação é a questão em aberto. Adicione testes de extract e inject com 4100 bytes em tests/propagators/test_w3cbaggagepropagator.py e verifique se os limites de 180 membros e 8192 bytes continuam valendo.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
Python
Estrelas
2.7k
Forks
1.1k
Merge médio
4d 13min
PRs com merge (30d)
38

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de open-telemetry/opentelemetry-python

Todas as issues de open-telemetry/opentelemetry-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.