Create an Android app and install Sentry NuGet package
Configure Sentry so that EnableBeforeSend is enabled and BeforeSend callback is set
Crash the app using SentrySdk.CauseCrash(CrashType.JavaBackgroundThread)
Expected Result
BeforeSend callback is fired, the java.lang.RuntimeException: This exception was caused deliberately by SentrySdk.CauseCrash(CrashType.JavaBackgroundThread) crash is reported.
Actual Result
The following crash is reported:
System.FormatException: One of the identified items was in an invalid format.
File "ThrowHelper.cs", line 594, in void ThrowHelper.ThrowFormatException()
throw new FormatException { Source = ExceptionSourceValueToRethrowAsJsonException };
File "JsonElement.cs", line 660, in int JsonElement.GetInt32()
ThrowHelper.ThrowFormatException();
File "Device.cs", line 459, in Device Device.FromJson(JsonElement json)
var processorFrequency = json.GetPropertyOrNull("processor_frequency")?.GetInt32();
File "SentryContexts.cs", line 148, in SentryContexts SentryContexts.FromJson(JsonElement json)
result[name] = Device.FromJson(value);
File "MiscExtensions.cs", line 5, in SentryContexts MiscExtensions.Pipe<JsonElement, SentryContexts>(JsonElement input, Func<JsonElement, SentryContexts> pipe)
public static TOut Pipe<TIn, TOut>(this TIn input, Func<TIn, TOut> pipe) => pipe(input);
File "SentryEvent.cs", line 305, in SentryEvent SentryEvent.FromJson(JsonElement json, Exception exception)
var contexts = json.GetPropertyOrNull("contexts")?.Pipe(SentryContexts.FromJson);
File "SentryEventExtensions.cs", line 29, in SentryEvent SentryEventExtensions.ToSentryEvent(SentryEvent sentryEvent, SentryOptions javaOptions)
return SentryEvent.FromJson(json.RootElement, sentryEvent.Throwable);
File "BeforeSendCallback.cs", line 26, in SentryEvent BeforeSendCallback.Execute(SentryEvent e, Hint h)
var evnt = e.ToSentryEvent(_javaOptions);
?, in IntPtr IBeforeSendCallbackInvoker.n_Execute_Lio_sentry_SentryEvent_Lio_sentry_Hint_(IntPtr jnienv, IntPtr native__this, IntPtr native_p0, IntPtr native_p1)
File "/Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs", line 231, col 5, in IntPtr JNINativeWrapper.Wrap_JniMarshal_PPLL_L(_JniMarshal_PPLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1)
This issue seems to be similar to #3465, the root cause seems to be a type mismatch for "processor_frequency" field:
Package
Sentry
.NET Flavor
.NET
.NET Version
8.0.303
OS
Android
SDK Version
4.10.0
Self-Hosted Sentry Version
No response
Steps to Reproduce
EnableBeforeSend
is enabled andBeforeSend
callback is setExpected Result
BeforeSend callback is fired, the
java.lang.RuntimeException: This exception was caused deliberately by SentrySdk.CauseCrash(CrashType.JavaBackgroundThread)
crash is reported.Actual Result
The following crash is reported:
This issue seems to be similar to #3465, the root cause seems to be a type mismatch for "processor_frequency" field:
Double
(https://github.com/getsentry/sentry-java/blob/9762f09afa51944b40a9b77e116a55e54636e6c5/sentry/src/main/java/io/sentry/protocol/Device.java#L693);Int32
(https://github.com/getsentry/sentry-dotnet/blob/0ab1ec98e5cca1cf2b2c134a659aa4f991fbe7fa/src/Sentry/Protocol/Device.cs#L459);