From fddb951480a25b2293d8e12a38244c1d9a9da7c3 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Tue, 4 Jul 2023 08:16:29 +0200 Subject: [PATCH] ref(sdk-crash-detection): Remove context detected 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. --- src/sentry/utils/sdk_crashes/sdk_crash_detection.py | 3 +-- .../utils/sdk_crashes/test_sdk_crash_detection.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/sentry/utils/sdk_crashes/sdk_crash_detection.py b/src/sentry/utils/sdk_crashes/sdk_crash_detection.py index 6e4de39b1b567..5eeb7a8ac50e9 100644 --- a/src/sentry/utils/sdk_crashes/sdk_crash_detection.py +++ b/src/sentry/utils/sdk_crashes/sdk_crash_detection.py @@ -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. @@ -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, }, diff --git a/tests/sentry/utils/sdk_crashes/test_sdk_crash_detection.py b/tests/sentry/utils/sdk_crashes/test_sdk_crash_detection.py index 03a7ab4b29336..7b231bf645d20 100644 --- a/tests/sentry/utils/sdk_crashes/test_sdk_crash_detection.py +++ b/tests/sentry/utils/sdk_crashes/test_sdk_crash_detection.py @@ -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, } @@ -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)