Skip to content

Sentry sdk causes requests to return an empty response when using graphql query #2285

Closed

Description

@reinoldus

How do you use Sentry?

Cloud

Version

1.29.0
python version: 3.9

Steps to Reproduce

import requests

from flask import Flask
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration

dsn = "XXXXX"

sentry_sdk.init(
    dsn=dsn,
    integrations=[
        FlaskIntegration(),
    ],
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production.
    traces_sample_rate=0.1,
)

headers = {
    "Content-Type": "application/json; charset=utf-8",
}
data = {
    "variables": {"email": "xxx"},
}


response = requests.post(
    "http://localhost:8089/v1/graphql",
    headers=headers,
    json=data,
)

x = response.json()


if you run the snippet above the response.content will come back as "", where if you run this:

import requests

from flask import Flask
# import sentry_sdk
# from sentry_sdk.integrations.flask import FlaskIntegration
#
# dsn = "httXXXXXXXX3611"
#
# sentry_sdk.init(
#     dsn=dsn,
#     integrations=[
#         FlaskIntegration(),
#     ],
#     # Set traces_sample_rate to 1.0 to capture 100%
#     # of transactions for performance monitoring.
#     # We recommend adjusting this value in production.
#     traces_sample_rate=0.1,
# )

headers = {
    "Content-Type": "application/json; charset=utf-8",
}
data = {
    "variables": {"email": "xxx"},
}


response = requests.post(
    "http://localhost:8089/v1/graphql",
    headers=headers,
    json=data,
)

x = response.json()

The response comes back as expected.

I am running the query against a hasura instance, but I assume it has something to do with this new feature, so I assume all requests to all graphql servers are affected:

image

Pip freeze:

annotated-types==0.5.0
asttokens==2.2.1
async-timeout==4.0.2
black==23.7.0
blinker==1.6.2
boto3==1.28.16
botocore==1.31.16
CacheControl==0.13.1
cachetools==5.3.1
certifi==2023.7.22
cffi==1.15.1
cfgv==3.3.1
charset-normalizer==3.2.0
click==8.1.6
colorama==0.4.6
contourpy==1.1.0
cryptography==41.0.2
cycler==0.11.0
Deprecated==1.2.14
distlib==0.3.7
dnspython==2.4.1
email-validator==2.0.0.post2
exceptiongroup==1.1.2
executing==1.2.0
filelock==3.12.2
firebase-admin==6.0.1
Flask==2.3.2
Flask-Cors==3.0.10
fonttools==4.41.1
google-api-core==2.11.1
google-api-python-client==2.95.0
google-auth==2.22.0
google-auth-httplib2==0.1.0
google-cloud-core==2.3.3
google-cloud-firestore==2.3.4
google-cloud-storage==2.10.0
google-crc32c==1.5.0
google-resumable-media==2.5.0
googleapis-common-protos==1.60.0
grpcio==1.56.2
grpcio-status==1.56.2
gunicorn==21.2.0
httplib2==0.22.0
icecream==2.1.3
identify==2.5.26
idna==3.4
importlib-metadata==6.8.0
importlib-resources==6.0.0
iniconfig==2.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
jmespath==1.0.1
jwcrypto==1.5.0
kiwisolver==1.4.4
MarkupSafe==2.1.3
matplotlib==3.7.2
msgpack==1.0.5
mypy-extensions==1.0.0
nodeenv==1.8.0
numpy==1.25.2
opencv-python-headless==4.8.0.74
packaging==23.1
pathspec==0.11.2
Pillow==10.0.0
pip==22.3.1
platformdirs==3.10.0
pluggy==1.2.0
pre-commit==3.3.3
proto-plus==1.22.3
protobuf==4.23.4
psycopg2-binary==2.9.6
pyasn1==0.5.0
pyasn1-modules==0.3.0
pycparser==2.21
pydantic==2.1.1
pydantic_core==2.4.0
Pygments==2.15.1
PyJWT==2.8.0
pyparsing==3.0.9
pytest==7.4.0
python-dateutil==2.8.2
python-dotenv==1.0.0
python-jwt==4.0.0
PyYAML==6.0.1
redis==4.6.0
requests==2.31.0
rsa==4.9
s3transfer==0.6.1
scipy==1.11.1
sentry-sdk==1.29.0
setuptools==65.5.1
six==1.16.0
tomli==2.0.1
typing_extensions==4.7.1
uritemplate==4.1.1
urllib3==1.26.16
virtualenv==20.24.2
Werkzeug==2.3.6
wheel==0.38.4
wrapt==1.15.0
zipp==3.16.2

Downgrading to 1.28.1 fixes the issue

Expected Result

Populated "text" field in requests response object

image

Actual Result

image (73)

The response is "stuck" in the raw HTTPResponse from urllib3

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Aug 1, 2023
  2. sentrivana commented on Aug 1, 2023

    @sentrivana
    Collaborator

    Hey @reinoldus, thanks for the report! Please downgrade to 1.28.1 for now, we're working on a fix.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Aug 1, 2023
  4. self-assigned this
    on Aug 1, 2023
  5. sentrivana commented on Aug 1, 2023

    @sentrivana
    Collaborator

    1.29.1 released now that should fix the issue.

  6. lpfann commented on Aug 1, 2023

    @lpfann

    Now we get a different issue with 1.29.1: (using sgqlc library)

      File "/venv/lib/python3.9/site-packages/sgqlc/endpoint/requests.py", line 216, in __call__
        with self.session.send(
      File "/venv/lib/python3.9/site-packages/requests/sessions.py", line 747, in send
        r.content
      File "/venv/lib/python3.9/site-packages/requests/models.py", line 899, in content
        self._content = b"".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b""
      File "/venv/lib/python3.9/site-packages/requests/models.py", line 818, in generate
        raise ChunkedEncodingError(e)
    requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'\\x1f\\x8b\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\x8c\\x91Ak\\xdc0\\x10\\x85\\xff\\x8b\\xae\\xcd\\x84\\x91mI+\\xdf\\x92\\xd2C \\x87@\\x1dr\\x08e\\x19K\\xe3D\\xc4\\xb6\\x8c\\xac\\xdd\\x12\\x96\\xfd\\xef\\x95\\xb7))=\\x15t\\xd0\\xcc|o\\x9ex:\\tO\\x99D{\\x12\\x13g\\xdaS\\xd8O\\xd1\\xf3x\\xacD\\xfb|\\x123M,Z\\xe1\\xa3', 0 bytes read)", InvalidChunkLength(got length b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x8c\x91Ak\xdc0\x10\x85\xff\x8b\xae\xcd\x84\x91mI+\xdf\x92\xd2C \x87@\x1dr\x08e\x19K\xe3D\xc4\xb6\x8c\xac\xdd\x12\x96\xfd\xef\x95\xb7))=\x15t\xd0\xcc|o\x9ex:\tO\x99D{\x12\x13g\xdaS\xd8O\xd1\xf3x\xacD\xfb|\x123M,Z\xe1\xa3', 0 bytes read))
    

    @sentrivana

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Aug 1, 2023
  8. sentrivana commented on Aug 1, 2023

    @sentrivana
    Collaborator

    @lpfann Thanks for reporting, looking into it. (In the meantime, downgrading to 1.28.1 will get rid of the issue.)

  9. MattLJoslin commented on Aug 1, 2023

    @MattLJoslin

    We're also seeing the same set of issues. Downgrading to 1.28.1 seems to fix for now.

  10. sentrivana commented on Aug 1, 2023

    @sentrivana
    Collaborator

    @lpfann Having trouble reproducing this -- anything specific about your setup? Maybe a small code sample?

  11. MattLJoslin commented on Aug 1, 2023

    @MattLJoslin

    We are using
    graphql-core==3.2.1
    gql==3.4.0
    requests==2.28.2
    urllib3==1.26.16

    this is a rough snippet of the code that is causing this issue

    import requests
    from gql import gql as gql_parse
    from gql.client import Client
    from gql.transport.requests import RequestsHTTPTransport

    query_str = """"""
    data_url = ""
    variables = {}
    userpass_data_headers = {}

    reqsession = requests.Session()
    adapter = requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100)
    reqsession.mount('https://', adapter)
    sync_transport = RequestsHTTPTransport(
    url=data_url, headers=userpass_data_headers
    )
    _client = Client(
    transport=sync_transport, fetch_schema_from_transport=True
    )
    session = _client.enter()
    query = gql_parse(query_str)
    data_obj = session.execute(query, variable_values=variables)

  12. sentrivana commented on Aug 1, 2023

    @sentrivana
    Collaborator

    Thanks a lot @MattLJoslin! This will help.

    I'll revert the feature that caused this for now so that more folks don't run into issues -- we'll revisit it later. Really sorry for the issues this caused.

  13. sentrivana commented on Aug 1, 2023

    @sentrivana
    Collaborator

    1.29.2 is now out and will get you all the good stuff from 1.29.0 without the GraphQL issues.

  14. MattLJoslin commented on Aug 1, 2023

    @MattLJoslin

    Thanks for the quick responses! We are still looking forward to this feature since we almost exclusively use graphql in our services, but appreciate the rollback :)

  15. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Aug 7, 2023
  16. ghost added on Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions