Skip to content

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

@kerenkhatiwada

Description

@kerenkhatiwada

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: 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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net codeBugSomething isn't workingNeeds Reproduction

    Projects

    Status

    No status

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions