Skip to content

fix(sdk-crashes): Ignore Dart SDK function #71545

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

Merged
merged 1 commit into from
May 28, 2024
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
8 changes: 4 additions & 4 deletions fixtures/sdk_crash_detection/crash_event_dart.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@


def get_frames(
sdk_frame_abs_path: str,
system_frame_abs_path: str,
sdk_frame_abs_path: str, system_frame_abs_path: str, sdk_function: str
) -> Sequence[MutableMapping[str, str]]:
frames = [
{
Expand All @@ -26,7 +25,7 @@ def get_frames(
"abs_path": "package:sentry_flutter_example/main.dart",
},
{
"function": "SentryTracer.setTag",
"function": sdk_function,
"filename": "sentry_tracer.dart",
"abs_path": sdk_frame_abs_path,
},
Expand All @@ -42,10 +41,11 @@ def get_frames(
def get_crash_event(
sdk_frame_abs_path="package:sentry/src/sentry_tracer.dart",
system_frame_abs_path="dart:core-patch/growable_array.dart",
sdk_function="SentryTracer.setTag",
**kwargs,
) -> dict[str, object]:
return get_crash_event_with_frames(
get_frames(sdk_frame_abs_path, system_frame_abs_path),
get_frames(sdk_frame_abs_path, system_frame_abs_path, sdk_function=sdk_function),
**kwargs,
)

Expand Down
4 changes: 3 additions & 1 deletion src/sentry/utils/sdk_crashes/sdk_crash_detection_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ def build_sdk_crash_detection_configs() -> Sequence[SDKCrashDetectionConfig]:
},
path_replacer=KeepFieldPathReplacer(fields={"package", "filename", "abs_path"}),
),
sdk_crash_ignore_functions_matchers=set(),
# SentryExceptionFactory.getSentryException is always part of the stacktrace when
# users capture exceptions and would cause false positives. Therefore, we ignore it.
sdk_crash_ignore_functions_matchers={"SentryExceptionFactory.getSentryException"},
)
configs.append(dart_config)

Expand Down
15 changes: 15 additions & 0 deletions tests/sentry/utils/sdk_crashes/test_sdk_crash_detection_dart.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ def test_sdk_crash_is_reported_with_flutter_paths(
assert mock_sdk_crash_reporter.report.call_count == 0


@decorators
def test_ignore_get_sentry_exception(mock_sdk_crash_reporter, mock_random, store_event, configs):
event_data = get_crash_event(sdk_function="SentryExceptionFactory.getSentryException")
event = store_event(data=event_data)

configs[1].organization_allowlist = [event.project.organization_id]

sdk_crash_detection.detect_sdk_crash(
event=event,
configs=configs,
)

assert mock_sdk_crash_reporter.report.call_count == 0


@decorators
def test_beta_sdk_version_detected(mock_sdk_crash_reporter, mock_random, store_event, configs):
event_data = get_crash_event()
Expand Down
Loading