Skip to content

feat: Sentry.AspNet now follows DataCollection for user info, cookies, headers, query strings and request bodies - #5983

Open
jamescrosswell wants to merge 2 commits into
mainfrom
ai/sentry-dotnet-5431-ebeec4
Open

jamescrosswell wants to merge 2 commits into
mainfrom
ai/sentry-dotnet-5431-ebeec4

Conversation

@jamescrosswell

Copy link
Copy Markdown
Collaborator

Sentry.AspNet (System.Web) now reads the DataCollection resolver instead of SendDefaultPii, both in SystemWebRequestEventProcessor and for the cookies StartSentryTransaction attaches to transactions.

Data Category
UserHostAddress, identity.Name, NameIdentifier claim UserInfo
Request.Cookies and the Cookie header Cookies
Request headers HttpHeaders.Request
Query string UrlQueryParams
Request body HttpBodies (IncomingRequest)

Part of #5420 (Phase 2).

Closes #5431

Behaviour

  • DataCollection not configured: unchanged. The resolver bridges each category to what SendDefaultPii did here before.
  • ConfigureDataCollection(...) called: each category decides and SendDefaultPii is ignored. An app that calls it with SendDefaultPii = false and keeps the defaults now gets the user, deny-listed cookies and a [Filtered] Cookie header from System.Web requests. This only affects apps that opted into the experimental option.

Notes for review

🤖 Generated with Claude Code

SystemWebRequestEventProcessor and StartSentryTransaction now read the
DataCollection resolver instead of SendDefaultPii: UserInfo gates the
user, Cookies the cookies and Cookie header, HttpHeaders.Request the
headers, UrlQueryParams the query string, and IncomingRequestBody whether
the body is read. MaxRequestBodySize still limits the body size.

Without ConfigureDataCollection the resolver bridges to SendDefaultPii,
so behaviour is unchanged.

Closes #5431

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit d5e4fa9.

Main concerns: data sent to Sentry, public contract, reach.

This label is a hint for reviewers, not an approval.

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to approve, with optional comments

Migrates every SendDefaultPii gate in Sentry.AspNet listed in #5431, plus request headers, to the DataCollectionResolver. When DataCollection isn't configured, each bridge resolves to what the old code did, and the call sites match #5980 for ASP.NET Core.

  • Optional: test/Sentry.AspNet.Tests/Internal/SystemWebRequestEventProcessorTests.cs: no test covers HttpHeaders.Request = Off with cookies still on, where Request.Cookies should still be captured. That's the System.Web equivalent of Populate_DataCollectionRequestHeadersOff_HeadersNotSetButCookiesAre in #5980. Here cookies come from Request.Cookies rather than the header loop, so it would pin that independence.

This is an automated preliminary review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 23, 2026
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.94%. Comparing base (1cdbd92) to head (d5e4fa9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5983      +/-   ##
==========================================
+ Coverage   77.92%   77.94%   +0.01%     
==========================================
  Files         535      535              
  Lines       19831    19838       +7     
  Branches     3967     3968       +1     
==========================================
+ Hits        15454    15463       +9     
+ Misses       3533     3532       -1     
+ Partials      844      843       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamescrosswell
jamescrosswell marked this pull request as ready for review November 23, 2026 03:22
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 23, 2026

@ric-oliv ric-oliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! While I was going through the user block, I noticed System.Web never sends the client's IP when user info is on, because the core enricher sets {{auto}} before the System.Web processor runs. That's been the case since 5.15.1, so it isn't from this PR. I opened #5985 for it.

One small thing about the description. The context.User?.Identity note says the processor threw and lost the event, but since #5688 the SDK logs a failing SDK processor and moves on. The event still went out, just without the username, claims, server name and request body. Maybe worth a tweak so the reason stays accurate?

This branch has not been deployed

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

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataCollection phase 2: migrate Sentry.AspNet (System.Web)

2 participants