getsentry / getsentry/sentry-dotnet

[MAUI] Local scope tags leak into subsequent HttpClient auto captured events

Open
#4,610 11 comments 0 reactions 0 assignees View on GitHub
.NET Bug Needs Reproduction
Dominant language
C#
Stars
770
Forks
248
Avg merge
3d 4h
Merged PRs (30d)
49

Description

### Package

Sentry

### .NET Flavor

.NET

### .NET Version

8.0.16

### OS

macOS

### OS Version

_No response_

### Development Environment

Visual Studio v17.x

### SDK Version

5.16.0

### Self-Hosted Sentry Version

_No response_

### Workload Versions

n/a

### UseSentry or SentrySdk.Init call

```
.UseSentry(options =>
{
options.Dsn = "";
options.TracesSampleRate = 1.0;
options.CaptureFailedRequests = true;
options.FailedRequestStatusCodes.Add((400, 499));
})
```

### Steps to Reproduce

Reported via [Zendesk ticket](https://sentry.zendesk.com/agent/tickets/164186): Tags set inside the local scope callback of `SentrySdk.CaptureException(error, scope => { ... })` are appearing on automatically captured HttpClient events. The tag (lats.EventName) is only set within the local callback and not configured globally, and it bleeds into later auto captured events.

Make a failing HTTP request (404) inside a try/catch. In catch, call:
`SentrySdk.CaptureException(ex, scope => { scope.SetTags(SetExtra(apiMethod, "http.error")); });`
This correctly sends an event with tag lats.EventName=testtag.

Make another failing HTTP request (500). The[ HttpClient integration](https://docs.sentry.io/platforms/dotnet/guides/maui/configuration/http-client-errors/) automatically captures an event.
That event still includes the tag lats.EventName=testtag even though it wasn’t set globally.

### Expected Result

Tags set in a local scope callback should not bleed to other automatically captured events.

### Actual Result

The automatically captured HttpClient event inherits tags from the local scope, even though that scope should have been isolated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.