Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2142,10 +2142,17 @@ def format_attribute(val: "Any") -> "AttributeValue":
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)
# Mixed-type or non-primitive list: preserve the array structure by
# coercing each element to a string. This matches sentry-javascript
# behaviour and avoids silently collapsing the whole array into a
# single string attribute value.
return [v if isinstance(v, str) else safe_repr(v) for v in val]
elif isinstance(val, tuple):
ty = type(val[0])
if ty in (str, int, float, bool) and all(type(v) is ty for v in val):
return list(val)
# Same treatment for tuples with mixed/non-primitive elements.
return [v if isinstance(v, str) else safe_repr(v) for v in val]

return safe_repr(val)

Expand Down