Skip to content

DataCollection phase 2: migrate GraphQL instrumentation #5432

Closed

Description

@jamescrosswell

Part of #5420. Phase 2 — behavior-neutral consumer migration.

Migrate the GraphQL client instrumentation to GraphQL.Document / GraphQL.Variables:

  • src/Sentry/SentryGraphQLHttpFailedRequestHandler.cs:67-80 — request query body (sentryRequest.Data) and response body currently gated on SendDefaultPii; split gating: document vs variables per spec.
  • src/Sentry/GraphQLContentExtractor.cs, GraphQLRequestContent.cs — extraction points.

Note the JS default: graphQL remains true even in the legacy-false bridge, because documents were historically attached (with redaction) — verify what sentry-dotnet's historical behavior implies for the bridge here (today the .NET handler attaches the body only when SendDefaultPii is true, so the .NET bridge should map false → GraphQL off, unlike JS).

Activity

  1. linear-code commented on Jul 22, 2026

    @linear-code
  2. jamescrosswell commented on Nov 8, 2026

    @jamescrosswell
    CollaboratorAuthor

    Legacy-gate accessors needed here too, beyond the GraphQL document

    Noting what reviewing #5885 turned up (thanks @ric-oliv). SentryGraphQLHttpFailedRequestHandler gates far more than the document on SendDefaultPii — when it is off, it attaches no request or response headers, neither cookie set, no request body and no response body, and strips user:pass@ and the fragment from Request.Url:

    Corrected 2026-11-10, again thanks to @ric-oliv: an earlier version of this note said the off branch "reduces Request.Url to scheme + host + path" and asked for a UrlQueryParamsWithLegacyPiiGate accessor. HttpRequestUrl() keeps the query string, so the URL gate here is about credentials, not query params. The accessor list below is rewritten, and the count drops from three to two.

    if (!_options.SendDefaultPii)
    {
        sentryRequest.Url = request.RequestUri?.HttpRequestUrl();   // keeps ?query; drops user:pass@ and #fragment
    }
    else
    {
        sentryRequest.Cookies = request.Headers.GetCookies();
        sentryRequest.Data = requestContent?.RequestContent;
        sentryRequest.Url = request.RequestUri?.AbsoluteUri;
        sentryRequest.AddHeaders(request.Headers);
        responseContext.Cookies = response.Headers.GetCookies();
        responseContext.Data = json;
        responseContext.AddHeaders(response.Headers);
    }

    DataCollectionResolver's global RequestHeaders / ResponseHeaders fall back to a plain DenyList() regardless of SendDefaultPii, because that matches the server-side capture path. Wiring this handler to them would start sending those headers for SendDefaultPii = false apps.

    What this needs:

    • RequestHeadersWithLegacyPiiGate and ResponseHeadersWithLegacyPiiGate — each Configured?.<category> ?? (SendDefaultPii ? DenyList : Off). DataCollection phase 2: migrate redact cascade and HTTP failed-request handler #5429 needs exactly these two for SentryHttpFailedRequestHandler, so whichever lands first adds them.
    • Cookies needs nothing extra — its global fallback is already Off when SendDefaultPii is false.
    • The bodies are already right: OutgoingRequestBody and IncomingResponseBody both fall back to SendDefaultPii, which is precisely what gates sentryRequest.Data and responseContext.Data above.
    • UrlQueryParams needs no gated variant, and covers both URL fields. HttpRequestUrl() keeps the query and Request.QueryString is set unconditionally outside the if, so the query reaches Sentry either way today; the global accessor keeps it flowing and filters the denylisted keys. SentryGraphQlHttpFailedRequestHandlerTests.cs:150 pins http://localhost/test/path?query=string with PII off, which a gated accessor resolving to Off would break.
    • The user:pass@ and fragment question is DataCollection phase 2: migrate redact cascade and HTTP failed-request handler #5429's to settle — see the credentials section of that note. Whatever it decides applies here verbatim: both handlers have the identical HttpRequestUrl() / AbsoluteUri split, and RedactUrl reaches neither.

    The document/variables split (GraphQLDocument, GraphQLVariables) is unchanged from the issue description: both fall back to SendDefaultPii, matching sentryRequest.Data.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net codeFeatureNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions