Skip to content

Commit 32505fb

Browse files
philipphofmannvolokluev
authored andcommitted
fix(sdk-crashes): Ignore Dart SDK function (#71545)
Ignore a specific dart SDK function to ignore false positives.
1 parent 5cf7940 commit 32505fb

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

fixtures/sdk_crash_detection/crash_event_dart.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44

55
def get_frames(
6-
sdk_frame_abs_path: str,
7-
system_frame_abs_path: str,
6+
sdk_frame_abs_path: str, system_frame_abs_path: str, sdk_function: str
87
) -> Sequence[MutableMapping[str, str]]:
98
frames = [
109
{
@@ -26,7 +25,7 @@ def get_frames(
2625
"abs_path": "package:sentry_flutter_example/main.dart",
2726
},
2827
{
29-
"function": "SentryTracer.setTag",
28+
"function": sdk_function,
3029
"filename": "sentry_tracer.dart",
3130
"abs_path": sdk_frame_abs_path,
3231
},
@@ -42,10 +41,11 @@ def get_frames(
4241
def get_crash_event(
4342
sdk_frame_abs_path="package:sentry/src/sentry_tracer.dart",
4443
system_frame_abs_path="dart:core-patch/growable_array.dart",
44+
sdk_function="SentryTracer.setTag",
4545
**kwargs,
4646
) -> dict[str, object]:
4747
return get_crash_event_with_frames(
48-
get_frames(sdk_frame_abs_path, system_frame_abs_path),
48+
get_frames(sdk_frame_abs_path, system_frame_abs_path, sdk_function=sdk_function),
4949
**kwargs,
5050
)
5151

src/sentry/utils/sdk_crashes/sdk_crash_detection_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ def build_sdk_crash_detection_configs() -> Sequence[SDKCrashDetectionConfig]:
293293
},
294294
path_replacer=KeepFieldPathReplacer(fields={"package", "filename", "abs_path"}),
295295
),
296-
sdk_crash_ignore_functions_matchers=set(),
296+
# SentryExceptionFactory.getSentryException is always part of the stacktrace when
297+
# users capture exceptions and would cause false positives. Therefore, we ignore it.
298+
sdk_crash_ignore_functions_matchers={"SentryExceptionFactory.getSentryException"},
297299
)
298300
configs.append(dart_config)
299301

tests/sentry/utils/sdk_crashes/test_sdk_crash_detection_dart.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ def test_sdk_crash_is_reported_with_flutter_paths(
142142
assert mock_sdk_crash_reporter.report.call_count == 0
143143

144144

145+
@decorators
146+
def test_ignore_get_sentry_exception(mock_sdk_crash_reporter, mock_random, store_event, configs):
147+
event_data = get_crash_event(sdk_function="SentryExceptionFactory.getSentryException")
148+
event = store_event(data=event_data)
149+
150+
configs[1].organization_allowlist = [event.project.organization_id]
151+
152+
sdk_crash_detection.detect_sdk_crash(
153+
event=event,
154+
configs=configs,
155+
)
156+
157+
assert mock_sdk_crash_reporter.report.call_count == 0
158+
159+
145160
@decorators
146161
def test_beta_sdk_version_detected(mock_sdk_crash_reporter, mock_random, store_event, configs):
147162
event_data = get_crash_event()

0 commit comments

Comments
 (0)