Skip to content

Commit f444d8a

Browse files
authored
feat(exception-group): Add new mechanism fields to Exception interface (#47643)
Mirrors the properties added in getsentry/relay#2020 Without this change the event endpoints will strip these values.
1 parent c8b844a commit f444d8a

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

src/sentry/interfaces/exception.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,19 @@ class Mechanism(Interface):
128128

129129
@classmethod
130130
def to_python(cls, data, **kwargs):
131-
for key in ("type", "synthetic", "description", "help_link", "handled", "data", "meta"):
131+
for key in (
132+
"type",
133+
"synthetic",
134+
"description",
135+
"help_link",
136+
"handled",
137+
"data",
138+
"meta",
139+
"source",
140+
"is_exception_group",
141+
"exception_id",
142+
"parent_id",
143+
):
132144
data.setdefault(key, None)
133145

134146
return super().to_python(data, **kwargs)
@@ -143,6 +155,10 @@ def to_json(self):
143155
"handled": self.handled,
144156
"data": self.data or None,
145157
"meta": prune_empty_keys(self.meta) or None,
158+
"source": self.source,
159+
"is_exception_group": self.is_exception_group,
160+
"exception_id": self.exception_id,
161+
"parent_id": self.parent_id,
146162
}
147163
)
148164

tests/sentry/event_manager/interfaces/snapshots/test_exception/test_context_with_mechanism.pysnap

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
created: '2019-04-30T08:25:08.436911Z'
2+
created: '2023-04-19T16:08:28.133847Z'
33
creator: sentry
44
source: tests/sentry/event_manager/interfaces/test_exception.py
55
---
@@ -9,6 +9,10 @@ get_api_context:
99
hasSystemFrames: true
1010
values:
1111
- mechanism:
12+
exception_id: 1
13+
is_exception_group: true
14+
parent_id: 0
15+
source: __context__
1216
type: generic
1317
module: foo.bar
1418
rawStacktrace: null
@@ -40,6 +44,10 @@ get_api_context:
4044
to_json:
4145
values:
4246
- mechanism:
47+
exception_id: 1
48+
is_exception_group: true
49+
parent_id: 0
50+
source: __context__
4351
type: generic
4452
module: foo.bar
4553
stacktrace:

tests/sentry/event_manager/interfaces/test_exception.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ def test_context_with_mechanism(make_exception_snapshot):
206206
"stacktrace": {
207207
"frames": [{"filename": "foo/baz.py", "lineno": 1, "in_app": True}]
208208
},
209-
"mechanism": {"type": "generic"},
209+
"mechanism": {
210+
"type": "generic",
211+
"source": "__context__",
212+
"is_exception_group": True,
213+
"exception_id": 1,
214+
"parent_id": 0,
215+
},
210216
}
211217
]
212218
)

0 commit comments

Comments
 (0)