Repository navigation
Description
Part of #5420. Phase 1 — foundation.
Add the internal resolved config and the legacy bridge; make it the single read path.
Note
The precedence below predates the non-nullable option shape landed in #5853; step 2 is now vacuous. See the resolution-model comment on this issue.
- Internal resolved view (all fields populated), exposed internally (e.g. via
SentryOptions). - Resolution precedence: (1) fields explicitly set on
DataCollection; (2) ifDataCollectionis configured at all (ConfigureDataCollectioncalled, or a value bound from configuration), missing fields use the new spec defaults (UserInfo=true, allHttpBodies, denyList behaviors); (3) ifDataCollectionis absent, derive everything fromSendDefaultPii:true→ everything on.false/unset →UserInfo=false,HttpBodies=None,GenAIoff,DatabaseQueryData=false, deny-lists extended with GDPR terms (forwarded,-ip,remote-,via,-user).
- If both
DataCollectionandSendDefaultPiiare set,SendDefaultPiiis ignored. - No consumer migrated yet — that happens per-area in Phase 2.
Decision: resolve-once vs. lazy per-call
The epic originally specified "resolve once at SDK init", copying JS (resolveDataCollectionOptions called in the Client constructor). sentry-java took the opposite approach: DataCollectionResolver holds a SentryOptions reference and recomputes on every query (isUserInfo(), getCookies(), …), with no cached snapshot.
Lazy is probably the better fit for .NET, because SentryOptions is a mutable object that callers can and do change after Init — a snapshot taken at init would silently ignore later edits, and options are also mutated in tests. The cost is recomputation per call, which matters on hot paths like header filtering, so consider caching the derived KeyValueCollectionBehavior values rather than the whole config.
Pick one explicitly here and note it in the epic; every Phase 2 issue reads through whatever this lands.
Legacy-gate variants may be needed per call site
sentry-java needed more than one accessor per category where integrations historically gated differently — e.g. isGraphqlDocument(), isGraphqlDocumentWithLegacyBodyGate(), isGraphqlDocumentWithLegacyAlways(). Expect the same in .NET (see #5432, where the GraphQL handler attaches the body only when SendDefaultPii is true, unlike JS). Design the resolver so a call site can ask for "resolved value, with this legacy fallback" instead of forcing one global bridge rule.
References: io.sentry.DataCollectionResolver (sentry-java 8.58.0); JS resolveDataCollectionOptions.ts / defaultPiiToCollectionOptions.ts (#20967, #20970).
Category list narrowed (2026-11-05). Mcp, Queues, FilePaths, StackFrameVariables and FrameContextLines were removed from DataCollectionOptions in #5853, as none has a consumer in the .NET SDK and the spec is still a candidate. See the deferred-categories note on #5420. This issue has been updated accordingly.
Activity
linear-code commentedon Jul 22, 2026
NET-761
jamescrosswell commentedon Nov 5, 2026
The option shape this issue was written against has changed (2026-11-05).
d18dd2ae4in #5853 replaced theSentryOptions.DataCollectionproperty withSentryOptions.ConfigureDataCollection(Action<DataCollectionOptions>), and every category onDataCollectionOptionsis now non-nullable with the spec default as its initializer. Rationale in #5853 (comment).That simplifies the resolution precedence this issue specifies, so the three-step rule above should be read as two steps:
options.DataCollection(nowinternal, still nullable) isnull→ nobody opted in → derive every category fromSendDefaultPii, exactly as step 3 describes.Step 2 of the original rule — "if
DataCollectionis configured at all, missing fields use the new spec defaults" — is now vacuous. There are no missing fields: the defaults live on the object, which is handed to the callback already complete. The resolver only has to implement theSendDefaultPiiderivation.Two consequences worth deciding here rather than in #5853:
SendDefaultPii = falsethat calls the callback only to restrict cookies, user info and HTTP bodies go back on. That is accepted as intended —DataCollectionis meant to replaceSendDefaultPii, not layer over it — and is documented onConfigureDataCollection. Flagging it because the resolver is where it becomes observable.DataCollection:Cookeis:Mode=Offcreates the options with nothing set, which now reads as "opted in, spec defaults" — i.e. a typo makes the SDK collect more thanSendDefaultPii = falsedid. The surrogate's own properties are all still nullable, soBindableSentryOptions.ApplyTocould instead create the options only when something actually bound. Not done in feat: add experimental DataCollection options, successor to SendDefaultPii #5853 because it changes behaviour for a section that binds nothing.feat: add experimental DataCollection options, successor to SendDefau…
jamescrosswell commentedon Nov 5, 2026
#5853 has merged (
eef24b160), and two things changed after the comment above.1.
KeyValueCollectionBehavioris now immutable. The public constructor and theMode/Termssetters are gone;Off,DenyList(...)andAllowList(...)are the only ways to build one. Reason: terms only mean something next to their mode, so in-place editing let code and configuration combine into a behavior neither side wrote — config supplyingTermswhile code setMode = AllowListproducedAllowList[those terms], and code appending a deny term to a config-set allow list widened it instead. A category is now replaced whole, from either side.Two consequences for the resolver:
KeyValueCollectionBehaviorvalues rather than the whole config" is now straightforward — instances are immutable, so one shared default instance can back every category with no aliasing risk. (That is also why the per-category independence test was deleted in this PR: it only meant something while they were mutable.)2. The XML docs now state that these options are inert, and this issue's PR has to delete that.
sentry-wardenflagged the docs as promising unimplemented behaviour — correct, since nothing insrc/readsDataCollectionexceptConfigureDataCollectioncreating it andBindableSentryOptions.ApplyTowriting it. The caveats to remove when the bridge lands:SentryOptions.ConfigureDataCollectionremarks — the opening paragraph ("The options are recorded but not yet consumed: no integration reads them, so what is collected is still governed entirely bySendDefaultPii, and restricting a category here has no effect yet"), and the paragraph after it, which states theSendDefaultPiireplacement in the future tense conditional on migration. That becomes present tense.DataCollectionOptionsclass remarks — the first line, "No integration reads these options yet, so setting a category has no effect on what is collected".If the bridge ships without touching these, the docs go stale in the misleading direction: they would understate what the SDK does.
3. The configuration opt-in trigger is decided: section presence stays the opt-in. Raised on the PR, and the call was that
DataCollectionis new enough that nobody gets the section without adding it deliberately. Worth recording the evidence, because it is broader than the typo the comment above describes — three shapes all opt in while silently dropping the value, each verified againstBindableSentryOptions.ApplyTo:DataCollection:Cookeis:Mode = Off(typo'd child key)CookiesatDenyList,UserInfo→true,HttpBodies→All"HttpBodies": []"Cookies": falseThe third is not a typo:
dataCollection.Cookies = falsecompiles in C# via the implicitboolconversion, so that is the natural translation into configuration, and the binder silently discards a scalar bound to a complex property. In all three the writer asked to restrict something and ended up opted in at permissive defaults withSendDefaultPii = falseignored — strictly more data than before.Documented rather than prevented, in the
KeyValueCollectionBehaviorandHttpBodiesremarks. It becomes consequential once this issue makes the options live, so if it is revisited: requiring a bound value before opting in fixes rows 1 and 2 only; row 3 needs the surrogate to accept a scalar bool.jamescrosswell commentedon Nov 5, 2026
Decisions settled, implemented in #5885.
Lazy, not resolve-once.
DataCollectionResolverholds theSentryOptionsand recomputes per query, asio.sentry.DataCollectionResolverdoes. A snapshot atInitwould silently ignore the later edits that both applications and tests make toSentryOptions. The two defaultKeyValueCollectionBehaviorinstances are cached statics, which is safe now that #5853 made them immutable.The bridge does not extend deny lists with the GDPR terms, contrary to this issue's text — that part came from the JS bridge, and following it would have made the Phase 2 header migration carry a behaviour change.
The .NET SDK has never filtered
X-Forwarded-Forand friends.SendDefaultPii = falseskips exactly one thing, theCookieheader (ScopeExtensions.cs:140,SystemWebRequestEventProcessor.cs:62); there is no forwarded/IP/Viafiltering anywhere insrc/. So headers and query params resolve to a plainDenyList()whateverSendDefaultPiisays, and cookies toOffwhen it is false. That is also what sentry-java's resolver actually does (explicitOrEmptyDenyList, andoff()for cookies) as opposed to what the spec prescribes for a from-scratch SDK. Turning those terms on by default for legacy users stays available as a deliberate change in #5422.Side effect: the
KeyValueCollectionBehavior.DenyListdoc shipped in #5853 claims those terms "restore the header filtering thatSendDefaultPiiapplied when disabled". There was no such filtering to restore, so #5885 rewords it to present them as the terms the spec names for filtering end-user-identifying keys.HTTP bodies resolve per direction —
IncomingRequestBody,OutgoingRequestBody,IncomingResponseBody,OutgoingResponseBody— rather than exposingHttpBodyTypes, since that is what a call site needs and sentry-java found the legacy gate differs per direction. In .NET all four fall back toSendDefaultPii, which is faithful: the GraphQL handler gates both client-side bodies on it, and incoming request bodies are governed byMaxRequestBodySize, an integration option that keeps taking precedence.Per-site legacy gates get a sibling accessor with that fallback, rather than bending the shared bridge — sentry-java's
isGraphqlDocumentWithLegacyBodyGate()pattern. None added yet, since none has a consumer until #5432.On the doc caveats (point 2 of the comment above): they are reworded rather than deleted. The resolver alone does not make the options live — nothing calls it until Phase 2 migrates the first consumer — so deleting the caveat now would have made the docs overstate what the SDK does, the mirror of the problem it was meant to fix.
ConfigureDataCollectionnow states theSendDefaultPiireplacement in the present tense, which is true of the resolver, and keeps a one-line caveat that the integrations are still being migrated. That line disappears for real as Phase 2 lands.jamescrosswell commentedon Nov 8, 2026
Correction to the decisions note above
Two things in the decisions comment were wrong, both caught by @ric-oliv reviewing #5885.
"
SendDefaultPii = falseonly skips theCookieheader" holds for the server-side capture path only (ScopeExtensions.cs:140,SystemWebRequestEventProcessor.cs:62).SentryHttpFailedRequestHandlerandSentryGraphQLHttpFailedRequestHandlerare all-or-nothing: no request or response headers, neither cookie set, andRequest.Urlreduced to scheme + host + path. The globalRequestHeaders/ResponseHeaders/UrlQueryParamsfallbacks are still right — they are faithful to the majority of call sites, and making them followSendDefaultPiiwould stop collecting all inbound request headers for everySendDefaultPii = falseapp — but the client-side handlers need the sibling accessors instead of the shared bridge."None added yet, since none has a consumer until #5432" therefore understated it: #5429 needs the same three
…WithLegacyPiiGateaccessors, and is likely to land first. Noted on #5429 and #5432 field by field, including thatRequest.QueryStringis set unconditionally today whileRequest.Urlis not, so those two fields migrate differently.Two further bridge details settled in the PR, neither of which was in the issue text:
IncomingRequestBodyfalls back totrue, notSendDefaultPii—MaxRequestBodySizehas always been its only gate (DataCollection phase 2: migrate Sentry.AspNetCore #5430).GenAI.Inputs/OutputsfollowSendDefaultPiialthough nothing gates AI content today, which makes DataCollection phase 2: migrate Sentry.Extensions.AI (GenAI) #5434 a deliberate user-visible change rather than a refactor (DataCollection phase 2: migrate Sentry.Extensions.AI (GenAI) #5434).#5420's bridge bullet now carries all of this.
ref: Add internal sensitive-data denylist and key-value filter utility (