Skip to content

Commit

Permalink
ref(sdk-crash-detection): Remove context detected
Browse files Browse the repository at this point in the history
Remove the detected field of sdk-crash-detection context,
as we can avoid an infinite processing loop by looking at the project_id
and event_id instead.
  • Loading branch information
philipphofmann committed Jul 4, 2023
1 parent f52e733 commit fddb951
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/sentry/utils/sdk_crashes/sdk_crash_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def detect_sdk_crash(self, event: Event, event_project_id: int) -> Optional[Even
return None

context = get_path(event.data, "contexts", "sdk_crash_detection")
if context is not None and context.get("detected", False):
if context is not None:
return None

# Getting the frames and checking if the event is unhandled might different per platform.
Expand All @@ -61,7 +61,6 @@ def detect_sdk_crash(self, event: Event, event_project_id: int) -> Optional[Even
"contexts",
"sdk_crash_detection",
value={
"detected": True,
"original_project_id": event.project.id,
"original_event_id": event.event_id,
},
Expand Down
11 changes: 9 additions & 2 deletions tests/sentry/utils/sdk_crashes/test_sdk_crash_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def execute_test(self, event_data, should_be_reported, mock_sdk_crash_reporter):

reported_event_data = mock_sdk_crash_reporter.report.call_args.args[0]
assert reported_event_data["contexts"]["sdk_crash_detection"] == {
"detected": True,
"original_project_id": event.project_id,
"original_event_id": event.event_id,
}
Expand Down Expand Up @@ -84,7 +83,15 @@ def test_no_exception_not_detected(self, mock_sdk_crash_reporter):
def test_sdk_crash_detected_event_is_not_reported(self, mock_sdk_crash_reporter):
event = get_crash_event()

set_path(event, "contexts", "sdk_crash_detection", value={"detected": True})
set_path(
event,
"contexts",
"sdk_crash_detection",
value={
"original_project_id": 1234,
"original_event_id": 1234,
},
)

self.execute_test(event, False, mock_sdk_crash_reporter)

Expand Down

0 comments on commit fddb951

Please sign in to comment.