Logs: array attribute values are silently dropped (and diverge from sentry-javascript)
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 64/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- python
- Domínio
- observability
Direção de pesquisa
Comece em sentry_sdk/utils.py, em format_attribute por volta da linha 2125, e rastreie como os atributos do logger são serializados antes da ingestão. Compare o comportamento do Python com o comportamento de fallback descrito de @sentry/core serializeAttributes. Está concluído quando valores não primitivos não desaparecerem mais silenciosamente e o comportamento de serialização ou diagnóstico escolhido estiver coberto pelas verificações existentes relevantes.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Environment
sentry-sdk 2.61.0, Python 3.14, logs enabled via enable_logs=True.
What happened
Passing a list-valued attribute to sentry_sdk.logger.* results in the attribute silently disappearing from the Logs UI — no value, no warning, no debug log.
sentry_sdk.logger.info(
"workflow_engine processed event",
attributes={
"workflow_ids": [101, 202, 303], # list[int] -> dropped (blank in UI)
"rule_names": ["high_cpu", "oom"], # list[str] -> dropped (blank in UI)
"organization_id": 42, # int -> stored OK
"mixed_list": [1, "two", 3.0], # mixed -> stored as the string "[1, 'two', 3.0]"
"nested_dict": {"a": [1, 2]}, # dict -> stored as the string "{'a': [1, 2]}"
},
)
Querying the log back (EAP logs dataset), the homogeneous scalar lists come back null, while the scalars and the stringified mixed/dict values are present.
Root cause
format_attribute (sentry_sdk/utils.py:2125) preserves a homogeneous scalar list/tuple as a real array, but falls back to safe_repr (a string) for mixed lists and objects:
elif isinstance(val, list):
ty = type(val[0])
if ty in (str, int, float, bool) and all(type(v) is ty for v in val):
return copy.deepcopy(val) # sent as a real array
...
return safe_repr(val) # everything else -> string
Sentry's log storage (EAP) only retains scalar attribute types (string / number / boolean), so the real arrays are dropped on ingestion. The net effect is counterintuitive: homogeneous lists vanish, but mixed lists/objects survive (as strings).
Divergence from sentry-javascript
@sentry/core (v10.50) does the opposite for logs — serializeAttributes(logAttributes, true) runs with fallback=true, so every non-primitive (arrays and objects) is JSON.stringify'd into a string attribute and shows up. Its attributes.js even has an explicit comment that it intentionally does not send real arrays yet to avoid a future breaking change. So the same logging API gives different results across SDKs.
Suggested fix
Make Python consistent with JS for now: stringify non-primitive attribute values (instead of sending homogeneous arrays that get dropped), or at minimum emit a debug log / drop-record when an attribute value can't be represented, so the loss isn't silent.
A docs note has been added in getsentry/sentry-docs#17921.
🤖 Generated with Claude Code
- Linguagem predominante
- Python
- Estrelas
- 2.2k
- Forks
- 680
- Merge médio
- 1d 1h
- PRs com merge (30d)
- 258
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de getsentry/sentry-python
-
Bug Python
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
getsentry/sentry-python#7827 · 4 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Bug Python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
getsentry/sentry-python#7774 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
Remove send_default_pii from asyncpgTalvez já em andamento @ericapisani assumiu há 1 dia. AbertaPython Task
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
getsentry/sentry-python#7652 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Python Task
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
getsentry/sentry-python#7569 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Docs Python
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
getsentry/sentry-python#7568 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de getsentry/sentry-python
Issues semelhantes
-
upstream update
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
conan-io/conan-center-index#31098 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
john-kurkowski/tldextract#382 ·
-
comp/tools duplicate P2 sweeper:risk-compatibility tool/mcp type/bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
NousResearch/hermes-agent#132042 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
deepset-ai/haystack#13092 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 85/100
feder-cr/invisible_playwright_mcp#1408 ·
Mantenedores costumam responder em até 1 dia