Skip to content

[Android] ArgumentException while processing Breadcrumbs #3851

Closed
@TimBurik

Description

@TimBurik

Package

Sentry

.NET Flavor

.NET

.NET Version

9.0.100

OS

Android

SDK Version

4.12.2

Self-Hosted Sentry Version

No response

Steps to Reproduce

  1. Initialize Sentry, enable BeforeSend feature
  2. Use the app, so that a breadcrumb with level = FATAL is generated
  3. Try to send a SentryEvent

Expected Result

Sentry event is processed and send to server

Actual Result

Sentry event is not processed, exception is thrown:

System.ArgumentException: Requested value 'fatal' was not found.
   at System.Enum.TryParseByName[UInt32](RuntimeType enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, UInt32& result)
   at System.Enum.TryParseByValueOrName[Int32,UInt32](RuntimeType enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, Int32& result)
   at System.Enum.TryParse(Type enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, Object& result)
   at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
   at Sentry.Internal.Extensions.EnumExtensions.ParseEnum[BreadcrumbLevel](String str)
   at Sentry.Breadcrumb.FromJson(JsonElement json)
   at System.Linq.Enumerable.SelectEnumerableIterator`2[[System.Text.Json.JsonElement, System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51],[Sentry.Breadcrumb, Sentry, Version=4.12.2.0, Culture=neutral, PublicKeyToken=fba2ec45388e2af0]].MoveNext()
   at System.Collections.Generic.List`1[[Sentry.Breadcrumb, Sentry, Version=4.12.2.0, Culture=neutral, PublicKeyToken=fba2ec45388e2af0]]..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[Breadcrumb](IEnumerable`1 source)
   at Sentry.SentryEvent.FromJson(JsonElement json, Exception exception)
   at Sentry.Android.Extensions.SentryEventExtensions.ToSentryEvent(SentryEvent sentryEvent, SentryOptions javaOptions)
   at Sentry.Android.Callbacks.BeforeSendCallback.Execute(SentryEvent e, Hint h)
   at Sentry.JavaSdk.SentryOptions.IBeforeSendCallbackInvoker.n_Execute_Lio_sentry_SentryEvent_Lio_sentry_Hint_(IntPtr jnienv, IntPtr native__this, IntPtr native_p0, IntPtr native_p1)

The issue seems to be caused by the mismatch in Breadcrumb.level types:
In sentry-java:
https://github.com/getsentry/sentry-java/blob/90eb1e3c65f721893b17bce4d286b482afccacb8/sentry/src/main/java/io/sentry/SentryLevel.java#L8-L13
In sentry-dotnet:

public enum BreadcrumbLevel
{
/// <summary>
/// Debug level.
/// </summary>
[EnumMember(Value = "debug")]
Debug = -1,
/// <summary>
/// Information level.
/// </summary>
/// <remarks>
/// This is value 0, hence, default.
/// </remarks>
[EnumMember(Value = "info")]
Info = 0, // Defaults to Info
/// <summary>
/// Warning breadcrumb level.
/// </summary>
[EnumMember(Value = "warning")]
Warning = 1,
/// <summary>
/// Error breadcrumb level.
/// </summary>
[EnumMember(Value = "error")]
Error = 2,
/// <summary>
/// Critical breadcrumb level.
/// </summary>
[EnumMember(Value = "critical")]
Critical = 3,
}

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

Projects

Status

Done

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions