Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Quart] sentry_patched_asgi_app() missing 1 required positional argument: 'send' #3040

Closed
KingsleyKelly opened this issue May 2, 2024 · 6 comments · Fixed by #3043
Closed
Assignees
Labels
Type: Bug Something isn't working

Comments

@KingsleyKelly
Copy link

KingsleyKelly commented May 2, 2024

How do you use Sentry?

Sentry Saas (sentry.io)

Version

latest

Steps to Reproduce

Requirements

aiohttp==3.8.1
annotated-types==0.6.0
anyio==4.2.0
blinker==1.7.0
beautifulsoup4==4.10.0
cachetools==5.3.2
certifi==2023.11.17
charset-normalizer==2.1.1
click==8.1.7
distro==1.9.0
quart
google-ads==21.3.0
google-api-core==2.15.0
google-api-python-client==2.15.0
google-auth==2.25.1
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.4.6
googleapis-common-protos==1.61.0
grpcio==1.59.3
grpcio-status==1.59.3
hypercorn
h11==0.14.0
httpcore==1.0.2
httplib2==0.22.0
httpx==0.26.0
idna==3.6
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
oauthlib==3.2.2
openai==1.6.1
packaging==23.2
proto-plus==1.22.3
protobuf==4.25.1
psycopg2-binary==2.9.9
pyasn1==0.5.1
pyasn1-modules==0.3.0
pydantic==2.5.3
pydantic_core==2.14.6
pyparsing==3.1.1
pytest==6.2.5
PyYAML==6.0.1
requests==2.31.0
requests-oauthlib==1.3.1
rsa==4.9
six==1.16.0
sniffio==1.3.0
tqdm==4.66.1
typing_extensions==4.9.0
uritemplate==3.0.1
urllib3==2.1.0
Werkzeug==3.0.1
protobuf==4.25.1
cachetools==5.3.2
mock==5.1.0
pytest-env==0.6.2
sentry-sdk[quart]
python-dotenv==0.19.1

Note that sentry, hypercorn and quart arent locked.

With the following invocation

import sentry_sdk
from sentry_sdk.integrations.quart import QuartIntegration
sentry_sdk.init(
    dsn="https://94e1b1ff4eb4da3636a3e8d55c2c0acf@o4506739227426816.ingest.sentry.io/4506739299254272",
    auto_enabling_integrations=False,
    integrations=[QuartIntegration()],
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    traces_sample_rate=1.0,
    # Set profiles_sample_rate to 1.0 to profile 100%
    # of sampled transactions.
    # We recommend adjusting this value in production.
    profiles_sample_rate=1.0,

It gives the following error

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/hypercorn/asyncio/task_group.py", line 27, in _handle
    await app(scope, receive, send, sync_spawn, call_soon)
  File "/usr/local/lib/python3.8/site-packages/hypercorn/app_wrappers.py", line 51, in __call__
    await self.handle_http(scope, receive, send, sync_spawn, call_soon)
  File "/usr/local/lib/python3.8/site-packages/hypercorn/app_wrappers.py", line 83, in handle_http
    await sync_spawn(self.run_app, environ, partial(call_soon, send))
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/hypercorn/app_wrappers.py", line 107, in run_app
    response_body = self.app(environ, start_response)
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/utils.py", line 1711, in runner
    return sentry_patched_function(*args, **kwargs)
TypeError: sentry_patched_asgi_app() missing 1 required positional argument: 'send' 

Expected Result

We can use Sentry

Actual Result

App 404s all requests

@Fwang36 Fwang36 changed the title sentry_patched_asgi_app() missing 1 required positional argument: 'send' [Quart] sentry_patched_asgi_app() missing 1 required positional argument: 'send' May 2, 2024
@KingsleyKelly
Copy link
Author

I resolved this by rolling back to version 1.

Is there a way this can fail gracefully in the future or raise an "This is an issue with the Sentry SDK" type error message as it was only after rolling back our app and all changes I realised it was Sentry, from the error I assumed a request being passed to sentry was malformed.

szokeasaurusrex added a commit to szokeasaurusrex/issue-reproductions that referenced this issue May 3, 2024
@szokeasaurusrex
Copy link
Member

Thanks for the issue report. This indeed appears to be a regression – I was able to reproduce the error here (although I received 500 status codes, not 404 as stated in this issue). But, the error message is the same.

@szokeasaurusrex szokeasaurusrex self-assigned this May 3, 2024
@szokeasaurusrex szokeasaurusrex added the Type: Bug Something isn't working label May 3, 2024
szokeasaurusrex added a commit that referenced this issue May 3, 2024
The Quart integration was completely broken prior to this commit, as it caused every request to fail with a 500 error. The reason was that we were using the non-async `ensure_integration_enabled` decorator on the async `sentry_patched_asgi_app` function. This commit fixes the issue by removing the use of that decorator, instead replacing it with a manual check for the integration being enabled.

Fixes GH-3040
@szokeasaurusrex
Copy link
Member

Hey @KingsleyKelly, so we have a fix (#3043) for this issue already. We plan to release the fix on Monday (May 6) in the morning (CET). Until then, please use version 1.x to work around this issue.

We apologize for any inconvenience caused by this bug.

@szokeasaurusrex
Copy link
Member

@KingsleyKelly We just released version 2.1.0, which should fix this problem!

@jay-tuckey
Copy link

Thanks @szokeasaurusrex I will give it a test tomorrow also.

@jay-tuckey
Copy link

Thanks @szokeasaurusrex I will give it a test tomorrow also.

Tested with both Quart and QuartTrio - all working well. Thanks for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants