René's URL Explorer Experiment


Title: Strawberry integration crashes if no query is in request · Issue #2715 · getsentry/sentry-python · GitHub

Open Graph Title: Strawberry integration crashes if no query is in request · Issue #2715 · getsentry/sentry-python

X Title: Strawberry integration crashes if no query is in request · Issue #2715 · getsentry/sentry-python

Description: How do you use Sentry? Sentry Saas (sentry.io) Version 1.40.2 Steps to Reproduce Running an app with the StrawberryIntegration crashes if graphql endpoint is called with no query field in the input data. Place the attached litestar app c...

Open Graph Description: How do you use Sentry? Sentry Saas (sentry.io) Version 1.40.2 Steps to Reproduce Running an app with the StrawberryIntegration crashes if graphql endpoint is called with no query field in the input...

X Description: How do you use Sentry? Sentry Saas (sentry.io) Version 1.40.2 Steps to Reproduce Running an app with the StrawberryIntegration crashes if graphql endpoint is called with no query field in the input...

Opengraph URL: https://github.com/getsentry/sentry-python/issues/2715

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Strawberry integration crashes if no query is in request","articleBody":"### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Version\n\n1.40.2\n\n### Steps to Reproduce\n\nRunning an app with the StrawberryIntegration crashes if graphql endpoint is called with no `query` field in the input data.\r\n\r\n1. Place the attached litestar app code in `app.py` and install the requirements (sentry, strawberry graphql and litestar)\r\n2. Run the local server using `litestar run`\r\n3. Call the graphql endpoint using `curl -v -X POST -d \"{}\" -H \"Content-Type: application/json\" http://localhost:8000/graphql`\r\n4. This causes an exception to be raised, whereas if I comment out the sentry_sdk.init() line in the code, the \"expected\" result of a 400 Bad Request is returned. \r\n5. (The additional unwanted effect is that the 500 exception goes to sentry as an error in a production app - this is just a minimal reproduction).\r\n\r\napp.py:\r\n\r\n```\r\nimport logging\r\n\r\nfrom litestar import Litestar\r\nfrom litestar.logging import LoggingConfig\r\n\r\nimport sentry_sdk\r\nfrom sentry_sdk.integrations.strawberry import StrawberryIntegration\r\n\r\nimport strawberry\r\nfrom strawberry.litestar import make_graphql_controller\r\n\r\nsentry_sdk.init(integrations=[StrawberryIntegration(async_execution=True)])\r\n\r\n\r\n@strawberry.type\r\nclass Query:\r\n    @strawberry.field\r\n    def hello(self) -> str:\r\n        return \"Hello World\"\r\n\r\n\r\nclass Schema(strawberry.Schema):\r\n    async def execute(self, *args, **kwargs):\r\n        try:\r\n            return await super().execute(*args, **kwargs)\r\n        except Exception as e:\r\n            logging.getLogger(\"root\").exception(e)\r\n            raise\r\n\r\n\r\nschema = Schema(Query)\r\n\r\nGraphQLController = make_graphql_controller(schema, path=\"/graphql\", debug=True)\r\n\r\napp = Litestar(\r\n    route_handlers=[GraphQLController],\r\n    logging_config=LoggingConfig(\r\n        root={\"level\": logging.getLevelName(logging.INFO), \"handlers\": [\"console\"]},\r\n        formatters={\r\n            \"standard\": {\r\n                \"format\": \"%(asctime)s - %(name)s - %(levelname)s - %(message)s\"\r\n            }\r\n        },\r\n    ),\r\n)\r\n```\r\n\r\npip freeze:\r\n\r\n```\r\nanyio==4.2.0\r\ncertifi==2024.2.2\r\nclick==8.1.7\r\nEditorConfig==0.12.3\r\nFaker==23.0.0\r\nfast-query-parsers==1.0.3\r\ngraphql-core==3.2.3\r\nh11==0.14.0\r\nhttpcore==1.0.2\r\nhttptools==0.6.1\r\nhttpx==0.26.0\r\nidna==3.6\r\nJinja2==3.1.3\r\njsbeautifier==1.14.11\r\nlitestar==2.6.0\r\nmarkdown-it-py==3.0.0\r\nMarkupSafe==2.1.5\r\nmdurl==0.1.2\r\nmsgspec==0.18.6\r\nmultidict==6.0.5\r\npolyfactory==2.14.1\r\nPygments==2.17.2\r\npython-dateutil==2.8.2\r\npython-dotenv==1.0.1\r\nPyYAML==6.0.1\r\nrich==13.7.0\r\nrich-click==1.7.3\r\nsentry-sdk==1.40.2\r\nsix==1.16.0\r\nsniffio==1.3.0\r\nstrawberry-graphql==0.219.1\r\ntyping_extensions==4.9.0\r\nurllib3==2.2.0\r\nuvicorn==0.27.0.post1\r\nuvloop==0.19.0\r\nwatchfiles==0.21.0\r\nwebsockets==12.0\r\n```\r\n\n\n### Expected Result\n\n```\r\n\u003c HTTP/1.1 400 Bad Request\r\n\u003c date: Wed, 07 Feb 2024 13:52:14 GMT\r\n\u003c server: uvicorn\r\n\u003c content-type: text/plain; charset=utf-8\r\n\u003c content-length: 37\r\n\u003c \r\n* Connection #0 to host localhost left intact\r\nNo GraphQL query found in the request⏎    \r\n```\r\n\n\n### Actual Result\n\n```\r\n\u003c HTTP/1.1 500 Internal Server Error\r\n\u003c date: Wed, 07 Feb 2024 13:53:11 GMT\r\n\u003c server: uvicorn\r\n\u003c content-type: application/json\r\n\u003c content-length: 52\r\n\u003c \r\n* Connection #0 to host localhost left intact\r\n{\"status_code\":500,\"detail\":\"Internal Server Error\"}⏎ \r\n```\r\n\r\nOn the server console, there is a traceback from inside the strawberry integration:\r\n\r\n```\r\n2024-02-07 13:53:11,970 - root - ERROR - 'NoneType' object has no attribute 'strip'\r\nTraceback (most recent call last):\r\n  File \"/Users/james/repos/sentrystrawberry/app.py\", line 25, in execute\r\n    return await super().execute(*args, **kwargs)\r\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"/Users/james/.pyenv/versions/3.12.0/envs/mixcloud/lib/python3.12/site-packages/strawberry/schema/schema.py\", line 263, in execute\r\n    result = await execute(\r\n             ^^^^^^^^^^^^^^\r\n  File \"/Users/james/.pyenv/versions/3.12.0/envs/mixcloud/lib/python3.12/site-packages/sentry_sdk/integrations/strawberry.py\", line 266, in _sentry_patched_execute_async\r\n    result = await old_execute_async(*args, **kwargs)\r\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"/Users/james/.pyenv/versions/3.12.0/envs/mixcloud/lib/python3.12/site-packages/strawberry/schema/execute.py\", line 91, in execute\r\n    async with extensions_runner.operation():\r\n  File \"/Users/james/.pyenv/versions/3.12.0/envs/mixcloud/lib/python3.12/site-packages/strawberry/extensions/context.py\", line 191, in __aenter__\r\n    await self.run_hooks_async()\r\n  File \"/Users/james/.pyenv/versions/3.12.0/envs/mixcloud/lib/python3.12/site-packages/strawberry/extensions/context.py\", line 177, in run_hooks_async\r\n    hook.initialized_hook.__next__()  # type: ignore[union-attr]\r\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"/Users/james/.pyenv/versions/3.12.0/envs/mixcloud/lib/python3.12/site-packages/sentry_sdk/integrations/strawberry.py\", line 148, in on_operation\r\n    if self.execution_context.query.strip().startswith(\"mutation\"):\r\n       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nAttributeError: 'NoneType' object has no attribute 'strip'\r\n```","author":{"url":"https://github.com/jthorniley","@type":"Person","name":"jthorniley"},"datePublished":"2024-02-07T14:02:37Z","url":"https://github.com/getsentry/sentry-python/issues/2715"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0f98dc46-a791-e8d6-5d5a-a013d1f331fc
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id92A4:36997C:211847:2E160F:6B00862B
html-safe-nonce0f136f8c85bbce5db1758a92231f51b97cbfa4e7237ba901f3a915a8f661ad3a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkE0OjM2OTk3QzoyMTE4NDc6MkUxNjBGOjZCMDA4NjJCIiwidmlzaXRvcl9pZCI6Ijg0NTA0ODAzNDI4ODM2NjU0NTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacef14617b04929244ec8c00e8ebb47ccebb8eb7c7db2cc5f644a9ce52c24c972d
hovercard-subject-tagissue:2123109584
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/2715/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6d6678d5cb706cf5848df5cc77c41e7ab25d603bcf2381e7a48fafbca11560f0/getsentry/sentry-python/issues/2715
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6d6678d5cb706cf5848df5cc77c41e7ab25d603bcf2381e7a48fafbca11560f0/getsentry/sentry-python/issues/2715
og:image:altHow do you use Sentry? Sentry Saas (sentry.io) Version 1.40.2 Steps to Reproduce Running an app with the StrawberryIntegration crashes if graphql endpoint is called with no query field in the input...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejthorniley
hostnamegithub.com
expected-hostnamegithub.com
None4d3d8e50f02c1d7bf86d5acfa1d3bfe9366abd6528a6b429eb07a168429d2b61
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id137814779
octolytics-dimension-repository_nwogetsentry/sentry-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id137814779
octolytics-dimension-repository_network_root_nwogetsentry/sentry-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasedb758f8e02b8257935fb03edf81a3e76eb3abd11
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-python/issues/2715#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F2715
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F2715
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-python
Reloadhttps://github.com/getsentry/sentry-python/issues/2715
Reloadhttps://github.com/getsentry/sentry-python/issues/2715
Reloadhttps://github.com/getsentry/sentry-python/issues/2715
getsentryhttps://github.com/getsentry
sentry-pythonhttps://github.com/getsentry/sentry-python
Codehttps://github.com/getsentry/sentry-python
Issues345 (345)https://github.com/getsentry/sentry-python/issues
Pull requests41 (41)https://github.com/getsentry/sentry-python/pulls
Discussionshttps://github.com/getsentry/sentry-python/discussions
Actionshttps://github.com/getsentry/sentry-python/actions
Security and quality2 (2)https://github.com/getsentry/sentry-python/security
Insightshttps://github.com/getsentry/sentry-python/insights
https://github.com/getsentry/sentry-python
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/2715
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/2715
#2762https://github.com/getsentry/sentry-python/pull/2762
Strawberry integration crashes if no query is in requesthttps://github.com/getsentry/sentry-python/issues/2715#top
#2762https://github.com/getsentry/sentry-python/pull/2762
https://github.com/antonpirker
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
Integration: Strawberryhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Integration%3A%20Strawberry%22
https://github.com/jthorniley
jthornileyhttps://github.com/jthorniley
on Feb 7, 2024https://github.com/getsentry/sentry-python/issues/2715#issue-2123109584
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Feb 7, 2024https://github.com/getsentry/sentry-python/issues/2715#event-11732895019
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
on Feb 7, 2024https://github.com/getsentry/sentry-python/issues/2715#event-14893106553
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
on Feb 7, 2024https://github.com/getsentry/sentry-python/issues/2715
sentrivanahttps://github.com/sentrivana
Type: Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Type%3A%20Bug%22
Integration: Strawberryhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Integration%3A%20Strawberry%22
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Feb 7, 2024https://github.com/getsentry/sentry-python/issues/2715#event-11732913048
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
on Feb 7, 2024https://github.com/getsentry/sentry-python/issues/2715
https://github.com/sentrivana
sentrivanahttps://github.com/sentrivana
on Feb 7, 2024https://github.com/getsentry/sentry-python/issues/2715#issuecomment-1932124842
@jthornileyhttps://github.com/jthorniley
sentrivanahttps://github.com/sentrivana
Good first issuehttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Good%20first%20issue%22
on Feb 7, 2024https://github.com/getsentry/sentry-python/issues/2715#event-11733513841
czyberhttps://github.com/czyber
on Feb 18, 2024https://github.com/getsentry/sentry-python/issues/2715#event-11841443865
fix(integrations): Handle None-value in GraphQL queryhttps://github.com/czyber/sentry-python/commit/a2526cc5cc00032e607729651f53fef0858082e1
https://docs.github.com/articles/closing-issues-via-commit-messages
a2526cchttps://github.com/czyber/sentry-python/commit/a2526cc5cc00032e607729651f53fef0858082e1
fix(integrations): Handle None-value in GraphQL query getsentry#2715https://github.com/czyber/sentry-python/commit/30f8f5812ceb5e12395409d8c5fc570f74b46808
getsentry#2715https://github.com/getsentry/sentry-python/issues/2715
https://docs.github.com/articles/closing-issues-via-commit-messages
30f8f58https://github.com/czyber/sentry-python/commit/30f8f5812ceb5e12395409d8c5fc570f74b46808
antonpirkerhttps://github.com/antonpirker
on Mar 12, 2024https://github.com/getsentry/sentry-python/issues/2715#event-12091004613
antonpirkerhttps://github.com/antonpirker
completedhttps://github.com/getsentry/sentry-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#2762https://github.com/getsentry/sentry-python/pull/2762
on Apr 4, 2024https://github.com/getsentry/sentry-python/issues/2715#event-12356888116
antonpirkerhttps://github.com/antonpirker
on Apr 4, 2024https://github.com/getsentry/sentry-python/issues/2715#event-12356888127
fix(integrations): Handle None-value in GraphQL query #2715 (#2762)https://github.com/getsentry/sentry-python/commit/a113ec8bbf4eb7b3e586651eb58d419f94dce3c8
#2715https://github.com/getsentry/sentry-python/issues/2715
#2762https://github.com/getsentry/sentry-python/pull/2762
a113ec8https://github.com/getsentry/sentry-python/commit/a113ec8bbf4eb7b3e586651eb58d419f94dce3c8
stephanie-andersonhttps://github.com/stephanie-anderson
Type: Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Type%3A%20Bug%22
on Nov 21, 2024https://github.com/getsentry/sentry-python/issues/2715#event-15380620243
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
on Aug 13, 2025https://github.com/getsentry/sentry-python/issues/2715#event-19125005396
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-python/issues/2715
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/2715
antonpirkerhttps://github.com/antonpirker
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
Integration: Strawberryhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Integration%3A%20Strawberry%22
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.