Skip to content

SetTag no longer allows null value #3946

@Cheesebaron

Description

@Cheesebaron

Package

Sentry

.NET Flavor

.NET

.NET Version

9.0.100

OS

iOS

SDK Version

5.1.0

Self-Hosted Sentry Version

No response

Steps to Reproduce

Some classes in our app don't have Nullable Attributes enabled and in previous versions of Sentry doing something like this was allowed:

string? value = null!;

SentrySdk.ConfigureScope(scope =>
{
    scope.SetTag("some-key", value);
});

However, with 5.1.0 it seems like this is not allowed any more and a ArgumentNullException is thrown:

Received unhandled Objective-C exception that was marshalled from a managed exception: ArgumentNull_Generic Arg_ParamName_Name, value (System.ArgumentNullException)
   at ObjCRuntime.ThrowHelper.ThrowArgumentNullException(String )
   at Sentry.CocoaSdk.SentryScope.SetTagValue(String value, String key)
   at Sentry.Cocoa.CocoaScopeObserver.<>c__DisplayClass5_0.<SetTag>b__0(SentryScope scope)
   at Sentry.CocoaSdk.SentrySDK.ConfigureScope(Action`1 callback)
   at Sentry.Cocoa.CocoaScopeObserver.SetTag(String , String )
   at Sentry.Scope.SetTag(String , String )
   at TrackMan.DrivingRangeApp.Crashes.SentryCrashReporter.<>c__DisplayClass2_0.<ConfigureGlobalScopeTags>b__0(Scope scope)
   at Sentry.Internal.SentryScopeManager.ConfigureScope(Action`1 )
   at Sentry.Internal.Hub.ConfigureScope(Action`1 )

Expected Result

Not sure what to expect, but sure the nullable attributes explicitly say value cannot be null. But previously it was allowed and I guess ignored internally.

Actual Result

See crash above.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions