Skip to content

gql: transport URL is sent as request.url without removing credentials #8216

Closed

Description

@Mohil-Ahuja

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.74.0 (master @ d565fed), gql 4.4.0, Python 3.12

Steps to Reproduce

import re

import responses
import sentry_sdk
from gql import Client, gql
from gql.transport.requests import RequestsHTTPTransport
from sentry_sdk.integrations.gql import GQLIntegration

events = []
sentry_sdk.init(
    dsn="https://public@example.invalid/1",
    integrations=[GQLIntegration()],
    send_default_pii=False,
    before_send=lambda e, h: events.append(e) or None,
)

url = "https://deploy-bot:s3cr3t@api.example.com/graphql?access_token=tok_live_123"
with responses.RequestsMock() as rsps:
    rsps.post(re.compile(r"https://.*api\.example\.com/graphql.*"), json={"errors": [{"message": "boom"}]})
    client = Client(transport=RequestsHTTPTransport(url=url))
    try:
        client.execute(gql("{ me { id } }"))
    except Exception:
        pass

print(events[0]["request"]["url"])

Expected Result

Credentials are removed from the URL, as parse_url does for the HTTP client integrations:

https://[Filtered]:[Filtered]@api.example.com/graphql

The query string would be kept out of url too.

Actual Result

https://deploy-bot:s3cr3t@api.example.com/graphql?access_token=tok_live_123

_request_info_from_transport in sentry_sdk/integrations/gql.py copies transport.url into event["request"]["url"] unchanged. This isn't gated on send_default_pii or data_collection, and EventScrubber doesn't look at request.url.

httpx, aiohttp, pyreqwest and stdlib all call parse_url(url, sanitize=False), so gql could do the same: put .url in url and .query in query_string. I'm happy to send a PR with a test if that approach works for you.

Activity

  1. linear-code commented on Nov 8, 2026

    @linear-code
  2. self-assigned this
    on Nov 9, 2026
  3. sentrivana commented on Nov 9, 2026

    @sentrivana
    Collaborator

    Hey @Mohil-Ahuja, thanks for the report! This is indeed a bug. If you already have a branch ready, feel free to submit a PR. Otherwise, we'll pick this up.

  4. added a commit that references this issue on Nov 10, 2026
    b898cd9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions