Repository navigation
feat: DataCollection now gates GraphQL error events, with separate document and variables options - #5934
Conversation
…aware filters Adds RequestHeadersWithLegacyPiiGate / ResponseHeadersWithLegacyPiiGate to DataCollectionResolver for the client-side failed-request handlers, restores CookieFilter.FilterSetCookieHeader, and lets the header, cookie and query string helpers take a KeyValueCollectionBehavior. All new parameters default to the current behaviour. Refs #5429 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Collection Headers use the legacy-gated accessors, cookies use Cookies and the query string (in Request.Url and Request.QueryString) uses UrlQueryParams. Response cookies now come from Set-Cookie, which responses send, rather than Cookie, which they never do. Refs #5429 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The GraphQL failed-request handler now reads the resolved DataCollection categories for the bodies it attaches, instead of SendDefaultPii: - The request body is an outgoing request body, so it is attached only when OutgoingRequestBody is collected. Inside it, the `query` (document) and `variables` members are kept or removed according to GraphQLDocument and GraphQLVariables. Batched requests are filtered per request; a body that is not a GraphQL request object is dropped when filtering is needed. - The response body is attached only when IncomingResponseBody is collected. This mirrors sentry-java's Apollo interceptors. Without ConfigureDataCollection every one of these categories falls back to SendDefaultPii, so the output is unchanged. Headers, cookies and the URL stay on SendDefaultPii until the shared accessors from #5429 land. Refs #5432 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…' into ai/dc-5432-graphql-5177a5
…ollection Uses the shared accessors from #5429, the same way SentryHttpFailedRequestHandler does: headers go through RequestHeadersWithLegacyPiiGate and ResponseHeadersWithLegacyPiiGate, cookies through Cookies, and Request.Url and Request.QueryString through UrlQueryParams. Response cookies now come from Set-Cookie, which responses send, rather than Cookie. Request.Url keeps the same SendDefaultPii split for user:pass@ and #fragment as the HTTP handler. Refs #5432 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
URL userinfo used to reach Sentry whenever SendDefaultPii was true. It is now filtered regardless of SendDefaultPii or DataCollection, as sentry-java and sentry-python already do and as the span-description spec requires: - the Redact() cascade over breadcrumbs, transaction and span descriptions runs for every event and transaction - RedactUrl only matches userinfo inside the URL authority, so an '@' in the path, query or later text no longer swallows the host - the failed-request Request.Url always drops userinfo and the fragment, and the fragment moves to the new SentryRequest.Fragment, as in sentry-java Refs #5429 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…' into ai/dc-5432-graphql-5177a5
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## ai/dc-5429-failed-request-0ffcba #5934 +/- ##
====================================================================
+ Coverage 77.81% 77.91% +0.10%
====================================================================
Files 535 535
Lines 19791 19831 +40
Branches 3958 3967 +9
====================================================================
+ Hits 15400 15451 +51
+ Misses 3543 3535 -8
+ Partials 848 845 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…' into ai/dc-5432-graphql-5177a5
…ureDataCollection Without ConfigureDataCollection, failed-request events with SendDefaultPii = false never carried the fragment: it was dropped along with the rest of the unfiltered URL. Keep that, and always send it once the app opts into DataCollection, as Java, Python and JS do. Refs #5429 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…' into ai/dc-5432-graphql-5177a5
The single method with a nullable behavior only matched the old rule because an empty DenyList adds nothing to the built-in terms. Restore the original one-liner for callers without a behavior and give the behavior-aware path its own overload, so AddHeaders chooses explicitly. Refs #5429 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…' into ai/dc-5432-graphql-5177a5
Matches QueryStringFilter.Filter and FilterHeaderValue. Refs #5429 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…yClient
Running Redact() on every event and transaction also rewrote breadcrumbs
and span descriptions the app set itself, which the Data Collection spec
forbids ("the SDK MUST NOT modify it"). Restore the SendDefaultPii gate in
SentryClient, as on main, and instead have SentryMessageHandler pass its
subclasses the URL with credentials replaced, per Structuring Data. Trace
propagation targets still match against the original URL. sentry-java
applies the same rule where each integration records a URL.
Refs #5429
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kills two mutants the mutation-testing check reported as surviving. Refs #5429 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
…' into ai/dc-5432-graphql-5177a5
There was a problem hiding this comment.
Good to approve, with optional comments
Closes #5432 as scoped: the GraphQL failed-request handler now reads every field from DataCollectionResolver, the legacy bridge keeps today's SendDefaultPii output, and GraphQL.Document / GraphQL.Variables filter the request body inside the OutgoingRequestBody gate. Tests cover the bridge, every document/variables combination, the body-type gates, batched bodies and malformed input.
- Optional:
GraphQL.Variables = falsedoesn't fully keep variable values out of the event. The exception message iserrors[0].message(src/Sentry/SentryGraphQLHttpFailedRequestHandler.cs, around line 35), andResponse.Datais gated only onIncomingResponseBody. Many servers echo bad variable values in error messages, for example graphql-js'sVariable "$id" got invalid value .... This was already true before this PR. A sentence in theGraphQLOptions.VariablesXML doc would set the right expectation. - Optional: when one GraphQL gate is off,
FilterRequestContent(src/Sentry/GraphQLRequestContent.cs) drops any body that isn't a JSON object or array, such as multipart upload requests, and logs nothing. Dropping it is the safe default, but aLogDebugthere would explain a missingRequest.Data. - Optional: variable values that are collected are attached raw, without the key-based denylist in
SensitiveDataFilter, so a variable namedpasswordis sent as-is. This matches the previousSendDefaultPii = truebehaviour, so a follow-up is fine if scrubbing is wanted.
This is an automated preliminary review.
…riables doesn't cover FilterRequestContent now logs at debug level when it drops a body it can't filter, so a missing Request.Data has an explanation. The GraphQLOptions.Variables doc notes that variable values echoed in server error messages and response bodies aren't filtered. Refs #5432 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fragments can carry tokens such as #access_token=..., so they now go through QueryStringFilter with the query's behaviour. With ConfigureDataCollection the fragment follows UrlQueryParams (Off drops it); without it, it is still sent only with SendDefaultPii = true, now through the sensitive deny list. Raised in sentry-junior's review of #5935. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Following up on the automated review:
|
FilteredHttpRequestUrl now formats the path with SafeUnescaped, so %2F, %3F, %23 and %40 stay encoded instead of turning into a path separator, an unfiltered query, a fragment or a userinfo '@'. Also from review on #5935: - RedactUrl skips the regex when the string has no '@'. - Its comment credits sentry-python, which also splits userinfo at the last '@'; sentry-java splits at the first. - QueryStringFilter.FilterUrl is back to main's one-argument form; nothing passed it a behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…' into ai/dc-5432-graphql-5177a5
…e instead of throwing JsonDocument.Parse accepts an escaped lone surrogate such as \ud83d, but NameEquals and WriteTo throw InvalidOperationException when they decode it. That escaped the JsonException catch, so HttpClient.Send threw instead of returning the response. Catch every exception, as the other parse failures already drop and log the body. Refs #5432 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…' into ai/dc-5432-graphql-5177a5
|
Mutation testing breaks the lines a PR changes on purpose, one mutation at a time, and checks that a test fails each time. A changed line no test runs fails the check, and a mutant that survives the tests only warns. Full report Sentry: tests caught 28 of 29 mutants on the changed lines
|
|
The surviving mutant at 🤖 Addressed by Claude Code |
Part of #5420 (Phase 2). Moves
SentryGraphQLHttpFailedRequestHandlerfromSendDefaultPiito the resolved DataCollection categories. WithoutConfigureDataCollection, every category falls back toSendDefaultPii, so bodies, headers and cookies come out as they do today. The exceptions are response cookies and the URL, both under "Worth flagging".What each field reads now
Request.Data(GraphQL request body)SendDefaultPiiOutgoingRequestBody, then thequery/variablesmembers kept or removed byGraphQL.Document/GraphQL.VariablesResponse.DataSendDefaultPiiIncomingResponseBodySendDefaultPiiRequestHeadersWithLegacyPiiGate/ResponseHeadersWithLegacyPiiGateRequest.Cookies/Response.CookiesSendDefaultPiiCookies. Response cookies now come fromSet-CookieRequest.Url/Request.QueryStringqueryUrlQueryParamsRequest.Urlcredentials and fragmentSendDefaultPiiRequest.Fragment, filtered like the query byUrlFragmentWithLegacyPiiGateHow the GraphQL categories combine with
httpBodiesThe handler attaches the raw HTTP request body, so that body is an outgoing request body first and a GraphQL document second. Both gates have to allow it:
OutgoingRequestBodydecides whether any request body is attached.FilterRequestContentremovesquerywhenGraphQL.Documentis off andvariableswhenGraphQL.Variablesis off. With both off it attaches nothing. Batched requests (a JSON array) are filtered per request. If a filter is needed and the body isn't a GraphQL request object, it is dropped instead of being sent unfiltered.This matches sentry-java's Apollo interceptors, the client-side counterpart to this handler:
isOutgoingRequestBody, thenGraphqlUtils.filterRequestBody. Java'sisGraphqlDocumentWithLegacyBodyGate()belongs to its server-side graphql-java reporter, which has no HTTP body. In .NET,GraphQLDocument/GraphQLVariablesalready fall back toSendDefaultPii, which is exactly what gated this body, so the resolver needs no new GraphQL accessor. Under the bridge, both gates areSendDefaultPiiand the body comes through byte-for-byte as before. Unlike the JS SDK, the bridge mapsSendDefaultPii = falseto "GraphQL off", because this handler never attached the document without it.The response body carries
dataanderrors, not the document or variables, so onlyIncomingResponseBodygates it.Worth flagging
Set-Cookie. The handler used to readCookiefrom the response, a header responses don't send, soResponse.Cookieswas always empty in practice. This follows DataCollection phase 2: migrate redact cascade and HTTP failed-request handler #5429's change to the HTTP handler;HandleResponse_Error_FiltersCookiesnow usesSet-Cookie.user:pass@and the fragment no longer reachRequest.Url, even withSendDefaultPii = true. This applies the decision recorded on DataCollection phase 2: migrate redact cascade and HTTP failed-request handler #5429 (DataCollection phase 2: migrate redact cascade and HTTP failed-request handler #5429 (comment)) verbatim, matching sentry-java and sentry-python. The fragment moves to the newSentryRequest.Fragment. It goes through the same filter as the query, via fix: always filter credentials from URLs, and apply DataCollection to failed HTTP request events #5935'sUrlFragmentWithLegacyPiiGate, because fragments can carry tokens such as#access_token=.... WithoutConfigureDataCollectionit's sent only withSendDefaultPii = true, as before, with sensitive values replaced by[Filtered]. With it, the fragment followsUrlQueryParams, andOffdrops it.Closes #5432
🤖 Generated with Claude Code