Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public void SetExtra(string key, object? value)

public void SetTag(string key, string value)
{
if (value is null)
{
_options.LogDebug("Tag with key '{0}' was null.", key);
return;
}

try
{
SentryCocoaSdk.ConfigureScope(scope => scope.SetTagValue(value, key));
Expand Down
18 changes: 18 additions & 0 deletions test/Sentry.Tests/ScopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,24 @@ public void Filtered_tags_are_not_set()

scope.Tags.Should().OnlyContain(pair => pair.Key == "AzFunctions" && pair.Value == "rule");
}

[Fact]
public void SetTag_NullValue_DoesNotThrowArgumentNullException()
{
var scope = new Scope();

ArgumentNullException exception = null;
try
{
scope.SetTag("IAmNull", null);
}
catch (ArgumentNullException e)
{
exception = e;
}

Assert.Null(exception);
}
}

public static class ScopeTestExtensions
Expand Down
Loading