Skip to content

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

@reinoldus

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions