Count `callback_error` for native Android events when `BeforeSend` throws

Open
#5,682 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
android, csharp
Domain
mobile-dev

Research direction

Start at src/Sentry/Platforms/Android/SentrySdk.cs lines 246-255 where BeforeSendWrapper returns null, and at BeforeSendCallback.Execute. The work is explicitly blocked on getsentry/sentry-java#6141 shipping and a Java SDK bump, so nothing is actionable yet: once it ships, bump the sentry-java dependency, then investigate on a physical/emulated Android device whether a thrown Java exception from the callback marshals across JNI so sentry-java counts callback_error instead of before_send. Done means a verified answer (with a device test) and, if it works, the wrapper changed from returning null to throwing.

Written by the indexing model from the issue text.

Description

.NET Bug Platform: Android

Part of #5634.

[Was] blocked by getsentry/sentry-java#6141, and a Java SDK bump to the release that ships it... this is no longer the case.

Branch: main. No public API change, and getsentry/sentry-java#6141 targets sentry-java 8.x, so the fix arrives with a regular Java SDK bump.

When the user's BeforeSend throws on a native Android event, #5610's BeforeSendWrapper returns null (Platforms/Android/SentrySdk.cs:246-255). sentry-java then counts before_send / error (SentryClient.java:171-177). sentry-java 8.58.0 has no callback_error reason yet (DiscardReason.java).

getsentry/sentry-java#6141 (part of getsentry/sentry-java#6081) adds DiscardReason.CALLBACK_ERROR and records it when a beforeSend* callback throws. sentry-java already drops the event on a throw; it just counts it as before_send today.

To investigate once it ships

Instead of returning null, BeforeSendCallback.Execute could throw a Java exception. sentry-java would then drop the event and count callback_error itself. This depends on how .NET for Android marshals managed exceptions across JNI, which needs checking on a device.

Dominant language
C#
Stars
775
Forks
262
Avg merge
1d 16h
Merged PRs (30d)
118

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-dotnet

All issues in getsentry/sentry-dotnet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.