Logs: array attribute values are silently dropped (and diverge from sentry-javascript)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 64/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- observability
Direzione di ricerca
Inizia in sentry_sdk/utils.py, in format_attribute intorno alla riga 2125, e traccia come vengono serializzati gli attributi del logger prima dell’ingestion. Confronta il comportamento di Python con il comportamento di fallback descritto di @sentry/core serializeAttributes. Il lavoro è completato quando i valori non primitivi non scompaiono più silenziosamente e il comportamento di serializzazione o diagnostica scelto è coperto dai controlli esistenti pertinenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 2.2k
- Fork
- 672
- Merge medio
- 23h 14m
- PR unite (30g)
- 218
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/sentry-python
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
getsentry/sentry-python#7543 · 2 commenti · 1 assegnatario ·
-
Python
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
getsentry/sentry-python#6992 · 1 commento ·
-
Improvement Python
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
getsentry/sentry-python#6970 · 1 commento ·
-
Bug Python
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
getsentry/sentry-python#6504 · 1 commento ·
-
Improvement Python Spans
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
getsentry/sentry-python#5833 · 1 commento ·
Tutte le issue di getsentry/sentry-python
Issue simili
-
货币战争手改优先级配置缺少列表元素类型校验(P3) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Apertaarea: ci bug perceived difficulty: 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ClickHouse/clickhouse-connect#1057 ·