Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(exception-group): Add new mechanism fields to Exception interface #47643

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
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
18 changes: 17 additions & 1 deletion src/sentry/interfaces/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,19 @@ class Mechanism(Interface):

@classmethod
def to_python(cls, data, **kwargs):
for key in ("type", "synthetic", "description", "help_link", "handled", "data", "meta"):
for key in (
"type",
"synthetic",
"description",
"help_link",
"handled",
"data",
"meta",
"source",
"is_exception_group",
"exception_id",
"parent_id",
):
data.setdefault(key, None)

return super().to_python(data, **kwargs)
Expand All @@ -143,6 +155,10 @@ def to_json(self):
"handled": self.handled,
"data": self.data or None,
"meta": prune_empty_keys(self.meta) or None,
"source": self.source,
"is_exception_group": self.is_exception_group,
"exception_id": self.exception_id,
"parent_id": self.parent_id,
}
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2019-04-30T08:25:08.436911Z'
created: '2023-04-19T16:08:28.133847Z'
creator: sentry
source: tests/sentry/event_manager/interfaces/test_exception.py
---
Expand All @@ -9,6 +9,10 @@ get_api_context:
hasSystemFrames: true
values:
- mechanism:
exception_id: 1
is_exception_group: true
parent_id: 0
source: __context__
type: generic
module: foo.bar
rawStacktrace: null
Expand Down Expand Up @@ -40,6 +44,10 @@ get_api_context:
to_json:
values:
- mechanism:
exception_id: 1
is_exception_group: true
parent_id: 0
source: __context__
type: generic
module: foo.bar
stacktrace:
Expand Down
8 changes: 7 additions & 1 deletion tests/sentry/event_manager/interfaces/test_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,13 @@ def test_context_with_mechanism(make_exception_snapshot):
"stacktrace": {
"frames": [{"filename": "foo/baz.py", "lineno": 1, "in_app": True}]
},
"mechanism": {"type": "generic"},
"mechanism": {
"type": "generic",
"source": "__context__",
"is_exception_group": True,
"exception_id": 1,
"parent_id": 0,
},
}
]
)
Expand Down