-
-
Notifications
You must be signed in to change notification settings - Fork 226
Closed
Labels
Description
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
- Create an Android app and install Sentry NuGet package
- Configure Sentry so that
EnableBeforeSendis enabled andBeforeSendcallback 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:
- Android native SDK serializes field as
Double(https://github.com/getsentry/sentry-java/blob/9762f09afa51944b40a9b77e116a55e54636e6c5/sentry/src/main/java/io/sentry/protocol/Device.java#L693); - .NET SDK tries to deserialize the same value as
Int32();sentry-dotnet/src/Sentry/Protocol/Device.cs
Line 459 in 0ab1ec9
var processorFrequency = json.GetPropertyOrNull("processor_frequency")?.GetInt32();
jamescrosswell
Metadata
Metadata
Assignees
Labels
Projects
Status
Done
Status
No status