Skip to content

JsonElementHasWrongType, String, Number #4018

Closed

Description

@jamescrosswell

Originally posted by @vyacheslav-volkov in #3851

I updated sentry to 5.2.0 (Android) and I see this unhandled error in logs, I think it's related:

System.InvalidOperationException: JsonElementHasWrongType, String, Number
  ?, in void ThrowHelper.ThrowJsonElementWrongTypeException(JsonTokenType, JsonTokenType)
  ?, in void JsonDocument.CheckExpectedType(JsonTokenType, JsonTokenType)
  ?, in string JsonDocument.GetString(int, JsonTokenType)
  ?, in string JsonElement.GetString()
  ?, in Dictionary<string, string> JsonExtensions.GetStringDictionaryOrNull(JsonElement)
  ?, in Breadcrumb Breadcrumb.FromJson(JsonElement json)
  ?, in bool SelectEnumerableIterator<JsonElement, Breadcrumb>.MoveNext()
  ?, in new List<Breadcrumb>(IEnumerable<Breadcrumb>)
  ?, in List<Breadcrumb> Enumerable.ToList<Breadcrumb>(IEnumerable<Breadcrumb>)
  ?, in SentryEvent SentryEvent.FromJson(JsonElement, Exception)
  ?, in SentryEvent SentryEventExtensions.ToSentryEvent(SentryEvent, SentryOptions)
  ?, in SentryEvent BeforeSendCallback.Execute(SentryEvent, Hint)
  ?, in IntPtr IBeforeSendCallbackInvoker.n_Execute_Lio_sentry_SentryEvent_Lio_sentry_Hint_(IntPtr jnienv, IntPtr native__this, IntPtr native_p0, IntPtr native_p1)
  ?, in IntPtr JNINativeWrapper.Wrap_JniMarshal_PPLL_L(_JniMarshal_PPLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1)

@aritchie I don't use custom breadcrumb data, I use this sentry settings for Android:

        options.Native.AnrEnabled = false;
        options.Native.EnableAppComponentBreadcrumbs = false;
        options.Native.EnableAppLifecycleBreadcrumbs = false;
        options.Native.EnableSystemEventBreadcrumbs = false;
        options.Native.EnableUserInteractionBreadcrumbs = false;
        options.Native.EnableActivityLifecycleBreadcrumbs = false;
        options.Native.EnableAutoActivityLifecycleTracing = false;

update 1: after I updated my app from sentry v4 to v5, I see errors in the log.

Activity

  1. vyacheslav-volkov commented on Mar 3, 2025

    @vyacheslav-volkov

    Maybe as a hotfix you will add a try-catch for this case and log it internally? The unhandled crash in the error tracking library is unacceptable.

  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Mar 3, 2025
  3. dartasen commented on Mar 3, 2025

    @dartasen

    I'm facing the same random issue

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 3, 2025
  5. aritchie commented on Mar 3, 2025

    @aritchie
    Contributor

    We'll look into this today and should be able to get it patched up this week.

  6. self-assigned this
    on Mar 3, 2025
  7. aritchie commented on Mar 3, 2025

    @aritchie
    Contributor

    @dartasen Could you please add any additional details you may have? Can you share your UseSentry call?

  8. added a commit that references this issue on Mar 3, 2025
  9. dartasen commented on Mar 3, 2025

    @dartasen

    @aritchie Sure, here is my Sentry setup for this error, nothing too fancy :

        private static MauiAppBuilder ConfigureSentry(this MauiAppBuilder builder)
        {
    
            return builder.UseSentry(static options =>
            {
                options.Dsn = [REDACTED]
                options.Release = AppInfo.VersionString;
    #if DEBUG
                options.Debug = false;
                options.Environment = "debug";
                options.DiagnosticLevel = SentryLevel.Info;
                options.TracesSampleRate = 1.0;
    #else
                options.Debug = false;
                options.Environment = "production";
                options.DiagnosticLevel = SentryLevel.Warning;
                options.TracesSampleRate = 0.25;
    #endif
                options.AutoSessionTracking = true;
                options.CaptureFailedRequests = false;
                options.IsGlobalModeEnabled = true;
                options.StackTraceMode = StackTraceMode.Enhanced;
                options.AttachScreenshot = true;
            });
        }

    About the details, nothing much to provide since it's happening inside of Sentry without specific action from the end user.
    Is there a built-in mechanism inside Sentry to disable breadcrumb collect and only toggle some of them ? Might help narrow down the issue to a specific category of data

  10. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Mar 3, 2025
  11. dartasen commented on Mar 4, 2025

    @dartasen

    @aritchie I dumped the parallel stack of my app booting up to this error, don't think it's that useful, but just in case.

    Image

    Image

  12. aritchie commented on Mar 4, 2025

    @aritchie
    Contributor

    @dartasen Appreciate the extra information. We are have a PR in that should fix up this issue.

  13. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 4, 2025
  14. dartasen commented on Mar 4, 2025

    @dartasen

    @aritchie Awesome, is there any nightly build feed so we can test beforehand to confirm that the issue is gone ?

  15. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Mar 4, 2025
  16. aritchie commented on Mar 4, 2025

    @aritchie
    Contributor

    @dartasen Not at this time. Sentry doesn't do beta releases at all that I'm aware of & definitely not in the dotnet space.

  17. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 4, 2025
  18. jamescrosswell commented on Mar 4, 2025

    @jamescrosswell
    CollaboratorAuthor

    @aritchie we can make pre-releases from a branch at any time. If you think that PR could benefit from some user testing (particularly since we can't reproduce the error ourselves), we could discuss this at the sync tomorrow.

  19. added a commit that references this issue on Mar 4, 2025
  20. AdamDiament commented on Mar 13, 2025

    @AdamDiament

    Upgrading to nuget version 5.3.0 has fixed this for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions