getsentry / sentry-python

The official Python SDK for Sentry.io
https://sentry.io/for/python/
MIT License
1.86k stars 486 forks source link

Adding sentry sdk leads to crashes in Django with Debug Toolbar #2101

Closed Mapiarz closed 9 months ago

Mapiarz commented 1 year ago

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.22.2

Steps to Reproduce

We have a django app which serves only to expose a single GraphQL endpoint. We are using Strawberry Django.

All queries will crash with both Django Debug Toolbar and Sentry enabled. If I disable sentry, all works. If I disable DDT, all works as well. Both enabled leads to all queries crashing in the same way.

Errors are correctly pushed to sentry.io, that's not a problem.

Expected Result

Queries should continue to work.

Actual Result

Queries don't work. Example:

{
   "event_id":"4e2ef202336c44db95a612bd66d46cd7",
   "project":4505165191839744,
   "release":"1424e8d9842aea48bbd99ff84fc14b28cd51198a",
   "dist":null,
   "platform":"python",
   "message":"",
   "datetime":"2023-05-11T12:15:07+00:00",
   "tags":[
      [
         "browser",
         "Firefox 112.0"
      ],
      [
         "browser.name",
         "Firefox"
      ],
      [
         "client_os.name",
         "Ubuntu"
      ],
      [
         "environment",
         "production"
      ],
      [
         "handled",
         "no"
      ],
      [
         "level",
         "error"
      ],
      [
         "mechanism",
         "django"
      ],
      [
         "runtime",
         "CPython 3.11.2"
      ],
      [
         "runtime.name",
         "CPython"
      ],
      [
         "release",
         "1424e8d9842aea48bbd99ff84fc14b28cd51198a"
      ],
      [
         "user",
         "id:3892ac33-5848-42e8-bd70-3f51a0bbee7e"
      ],
      [
         "server_name",
         "6714387b6a2c"
      ],
      [
         "transaction",
         "/graphql"
      ],
      [
         "url",
         "http://127.0.0.1:8000/graphql"
      ]
   ],
   "_meta":{
      "request":{
         "headers":{
            "13":{
               "1":{
                  "":{
                     "rem":[
                        [
                           "@password:filter",
                           "s",
                           0,
                           10
                        ]
                     ],
                     "len":64
                  }
               }
            }
         }
      }
   },
   "_metrics":{
      "bytes.ingested.event":16107,
      "bytes.stored.event":18730
   },
   "breadcrumbs":{
      "values":[
         {
            "timestamp":1683807307.061408,
            "type":"default",
            "category":"query",
            "level":"info",
            "message":"connect"
         },
         {
            "timestamp":1683807307.065424,
            "type":"default",
            "category":"query",
            "level":"info",
            "message":"INSERT INTO \"silk_request\" (\"id\", \"path\", \"query_params\", \"raw_body\", \"body\", \"method\", \"start_time\", \"view_name\", \"end_time\", \"time_taken\", \"encoded_headers\", \"meta_time\", \"meta_num_queries\", \"meta_time_spent_queries\", \"pyprofile\", \"prof_file\", \"num_sql_queries\") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
         },
         {
            "timestamp":1683807307.091856,
            "type":"default",
            "category":"query",
            "level":"info",
            "message":"SELECT \"bookings_boatbooking\".\"id\", \"bookings_boatbooking\".\"reference\" FROM \"bookings_boatbooking\" WHERE (\"bookings_boatbooking\".\"fleet_operator_id\" = %s AND NOT \"bookings_boatbooking\".\"is_deleted\") LIMIT 1000"
         },
         {
            "timestamp":1683807307.094271,
            "type":"default",
            "category":"query",
            "level":"info",
            "message":"EXPLAIN (ANALYZE true) SELECT \"bookings_boatbooking\".\"id\", \"bookings_boatbooking\".\"reference\" FROM \"bookings_boatbooking\" WHERE (\"bookings_boatbooking\".\"fleet_operator_id\" = %s AND NOT \"bookings_boatbooking\".\"is_deleted\") LIMIT 1000"
         },
         {
            "timestamp":1683807307.100715,
            "type":"log",
            "category":"foobar.app.core.logging.graphql",
            "level":"info",
            "message":"{'time': 19470901, 'operation': 'allBookings', 'event': 'graphql', 'user': <foobarUser: demo@foobar.com>, 'rid': 'bf942fa4-45b9-4d29-827d-b523aadb55e9', 'fo': <FleetOperator: Galaxy Charters>, 'timestamp': '2023-05-11T12:15:07.100656Z', 'logger': 'foobar.app.core.logging.graphql', 'level': 'info'}"
         }
      ]
   },
   "contexts":{
      "browser":{
         "name":"Firefox",
         "version":"112.0",
         "type":"browser"
      },
      "client_os":{
         "name":"Ubuntu",
         "type":"os"
      },
      "runtime":{
         "name":"CPython",
         "version":"3.11.2",
         "build":"3.11.2 (main, Mar  1 2023, 14:46:02) [GCC 10.2.1 20210110]",
         "type":"runtime"
      },
      "trace":{
         "trace_id":"393ac660c1a0423b871a282ef190d1d8",
         "span_id":"9fdfdce1ad02a1eb",
         "parent_span_id":"b2e9d5b636ad1352",
         "op":"event.django",
         "status":"unknown",
         "client_sample_rate":0.0,
         "description":"sentry_sdk.integrations.django._got_request_exception",
         "type":"trace"
      }
   },
   "culprit":"/graphql",
   "environment":"production",
   "exception":{
      "values":[
         {
            "type":"AttributeError",
            "value":"'function' object has no attribute '__func__'",
            "stacktrace":{
               "frames":[
                  {
                     "function":"inner",
                     "module":"django.core.handlers.exception",
                     "filename":"django/core/handlers/exception.py",
                     "abs_path":"/workspace/backend/.venv/lib/python3.11/site-packages/django/core/handlers/exception.py",
                     "lineno":47,
                     "pre_context":[
                        "        return inner",
                        "    else:",
                        "        @wraps(get_response)",
                        "        def inner(request):",
                        "            try:"
                     ],
                     "context_line":"                response = get_response(request)",
                     "post_context":[
                        "            except Exception as exc:",
                        "                response = response_for_exception(request, exc)",
                        "            return response",
                        "        return inner",
                        ""
                     ],
                     "in_app":false,
                     "vars":{
                        "exc":"AttributeError(\"'function' object has no attribute '__func__'\")",
                        "get_response":"<strawberry_django_plus.middlewares.debug_toolbar.DebugToolbarMiddleware object at 0x7f8775a15250>",
                        "request":"<WSGIRequest: POST '/graphql'>"
                     }
                  },
                  {
                     "function":"__call__",
                     "module":"strawberry_django_plus.middlewares.debug_toolbar",
                     "filename":"strawberry_django_plus/middlewares/debug_toolbar.py",
                     "abs_path":"/workspace/backend/.venv/lib/python3.11/site-packages/strawberry_django_plus/middlewares/debug_toolbar.py",
                     "lineno":140,
                     "pre_context":[
                        "            return self.__acall__(request)",
                        "",
                        "        if _is_websocket(request):",
                        "            return self._original_get_response(request)",
                        ""
                     ],
                     "context_line":"        return self.process_request(request)",
                     "post_context":[
                        "",
                        "    async def __acall__(self, request: HttpRequest):",
                        "        if _is_websocket(request):",
                        "            return await self._original_get_response(request)",
                        ""
                     ],
                     "in_app":false,
                     "vars":{
                        "request":"<WSGIRequest: POST '/graphql'>",
                        "self":"<strawberry_django_plus.middlewares.debug_toolbar.DebugToolbarMiddleware object at 0x7f8775a151d0>"
                     }
                  },
                  {
                     "function":"process_request",
                     "module":"strawberry_django_plus.middlewares.debug_toolbar",
                     "filename":"strawberry_django_plus/middlewares/debug_toolbar.py",
                     "abs_path":"/workspace/backend/.venv/lib/python3.11/site-packages/strawberry_django_plus/middlewares/debug_toolbar.py",
                     "lineno":149,
                     "pre_context":[
                        "            return await self._original_get_response(request)",
                        "",
                        "        return await sync_to_async(self.process_request, thread_sensitive=False)(request)",
                        "",
                        "    def process_request(self, request: HttpRequest):"
                     ],
                     "context_line":"        response = super().__call__(request)",
                     "post_context":[
                        "",
                        "        if not show_toolbar(request) or DebugToolbar.is_toolbar_request(request):",
                        "            return response",
                        "",
                        "        content_type = response.get(\"Content-Type\", \"\").split(\";\")[0]"
                     ],
                     "in_app":false,
                     "vars":{
                        "__class__":"<class 'strawberry_django_plus.middlewares.debug_toolbar.DebugToolbarMiddleware'>",
                        "request":"<WSGIRequest: POST '/graphql'>",
                        "self":"<strawberry_django_plus.middlewares.debug_toolbar.DebugToolbarMiddleware object at 0x7f8775a151d0>"
                     }
                  },
                  {
                     "function":"__call__",
                     "module":"debug_toolbar.middleware",
                     "filename":"debug_toolbar/middleware.py",
                     "abs_path":"/workspace/backend/.venv/lib/python3.11/site-packages/debug_toolbar/middleware.py",
                     "lineno":64,
                     "pre_context":[
                        "        finally:",
                        "            clear_stack_trace_caches()",
                        "            # Deactivate instrumentation ie. monkey-unpatch. This must run",
                        "            # regardless of the response. Keep 'return' clauses below.",
                        "            for panel in reversed(toolbar.enabled_panels):"
                     ],
                     "context_line":"                panel.disable_instrumentation()",
                     "post_context":[
                        "",
                        "        # Generate the stats for all requests when the toolbar is being shown,",
                        "        # but not necessarily inserted.",
                        "        for panel in reversed(toolbar.enabled_panels):",
                        "            panel.generate_stats(request, response)"
                     ],
                     "in_app":false,
                     "vars":{
                        "panel":"<debug_toolbar.panels.cache.CachePanel object at 0x7f8767de7bd0>",
                        "request":"<WSGIRequest: POST '/graphql'>",
                        "response":"<HttpResponse status_code=200, \"application/json\">",
                        "self":"<strawberry_django_plus.middlewares.debug_toolbar.DebugToolbarMiddleware object at 0x7f8775a151d0>",
                        "show_toolbar":"<function show_toolbar at 0x7f8777a57380>",
                        "toolbar":"<debug_toolbar.toolbar.DebugToolbar object at 0x7f8767de61d0>"
                     }
                  },
                  {
                     "function":"disable_instrumentation",
                     "module":"debug_toolbar.panels.cache",
                     "filename":"debug_toolbar/panels/cache.py",
                     "abs_path":"/workspace/backend/.venv/lib/python3.11/site-packages/debug_toolbar/panels/cache.py",
                     "lineno":217,
                     "pre_context":[
                        "",
                        "    def disable_instrumentation(self):",
                        "        if hasattr(self._context_locals, \"current_instance\"):",
                        "            del self._context_locals.current_instance",
                        "        for cache in caches.all(initialized_only=True):"
                     ],
                     "context_line":"            self._unmonkey_patch_cache(cache)",
                     "post_context":[
                        "",
                        "    def generate_stats(self, request, response):",
                        "        self.record_stats(",
                        "            {",
                        "                \"total_calls\": len(self.calls),"
                     ],
                     "in_app":false,
                     "vars":{
                        "cache":"<django.core.cache.backends.locmem.LocMemCache object at 0x7f8774d44550>",
                        "self":"<debug_toolbar.panels.cache.CachePanel object at 0x7f8767de7bd0>"
                     }
                  },
                  {
                     "function":"_unmonkey_patch_cache",
                     "module":"debug_toolbar.panels.cache",
                     "filename":"debug_toolbar/panels/cache.py",
                     "abs_path":"/workspace/backend/.venv/lib/python3.11/site-packages/debug_toolbar/panels/cache.py",
                     "lineno":171,
                     "pre_context":[
                        "    @staticmethod",
                        "    def _unmonkey_patch_cache(cache):",
                        "        if hasattr(cache, \"_djdt_patched\"):",
                        "            for name in WRAPPED_CACHE_METHODS:",
                        "                original_method = getattr(cache, name)._djdt_wrapped"
                     ],
                     "context_line":"                if original_method.__func__ == getattr(cache.__class__, name):",
                     "post_context":[
                        "                    delattr(cache, name)",
                        "                else:",
                        "                    setattr(cache, name, original_method)",
                        "            del cache._djdt_patched",
                        "            del cache._djdt_recording"
                     ],
                     "in_app":false,
                     "vars":{
                        "cache":"<django.core.cache.backends.locmem.LocMemCache object at 0x7f8774d44550>",
                        "name":"'get'",
                        "original_method":"<function LocMemCache.get at 0x7f8767e0da80>"
                     }
                  }
               ]
            },
            "mechanism":{
               "type":"django",
               "handled":false
            }
         }
      ]
   },
   "extra":{
      "sys.argv":[
         "manage.py",
         "runserver",
         "0.0.0.0:8000"
      ]
   },
   "fingerprint":[
      "{{ default }}"
   ],
   "grouping_config":{
      "enhancements":"eJybzDRxY3J-bm5-npWRgaGlroGxrpHxBABcYgcZ",
      "id":"newstyle:2019-10-29"
   },
   "hashes":[
      "52e0cdead9052e9438d858fb9a6fabb5"
   ],
   "ingest_path":[
      {
         "version":"23.4.0",
         "public_key":"XE7QiyuNlja9PZ7I9qJlwQotzecWrUIN91BAO7Q5R38"
      }
   ],
   "key_id":"3133420",
   "level":"error",
   "location":"debug_toolbar/panels/cache.py",
   "logger":"",
   "metadata":{
      "display_title_with_tree_label":false,
      "filename":"debug_toolbar/panels/cache.py",
      "function":"_unmonkey_patch_cache",
      "type":"AttributeError",
      "value":"'function' object has no attribute '__func__'"
   },
   "modules":{
      "aenum":"3.1.11",
      "alabaster":"0.7.13",
      "amqp":"5.1.1",
      "api2pdf":"0.0.11",
      "asgiref":"3.6.0",
      "asttokens":"2.2.1",
      "attrs":"22.2.0",
      "autopep8":"2.0.1",
      "aws-xray-sdk":"2.5.0",
      "babel":"2.11.0",
      "backcall":"0.2.0",
      "billiard":"3.6.4.0",
      "black":"22.12.0",
      "boto3":"1.26.78",
      "boto3-stubs":"1.26.78",
      "botocore":"1.29.78",
      "botocore-stubs":"1.29.78",
      "brotli":"1.0.9",
      "cachecontrol":"0.12.11",
      "cachetools":"5.3.0",
      "celery":"5.2.7",
      "celery-types":"0.14.0",
      "certifi":"2022.12.7",
      "cffi":"1.15.1",
      "charset-normalizer":"3.0.1",
      "click":"8.1.3",
      "click-didyoumean":"0.3.0",
      "click-plugins":"1.1.1",
      "click-repl":"0.2.0",
      "comm":"0.1.2",
      "commonmark":"0.9.1",
      "coreapi":"2.3.3",
      "coreschema":"0.0.4",
      "cron-descriptor":"1.2.35",
      "cryptography":"38.0.4",
      "cssselect2":"0.7.0",
      "debugpy":"1.6.6",
      "decorator":"5.1.1",
      "defusedxml":"0.7.1",
      "deprecated":"1.2.13",
      "diff-match-patch":"20200713",
      "dj-database-url":"1.2.0",
      "django":"3.2.18",
      "django-appconf":"1.0.5",
      "django-celery-beat":"2.5.0",
      "django-celery-results":"2.5.0",
      "django-choices-field":"2.1",
      "django-cleanup":"6.0.0",
      "django-cors-headers":"3.13.0",
      "django-countries":"7.5.1",
      "django-debug-toolbar":"3.8.1",
      "django-environ":"0.9.0",
      "django-extensions":"3.2.1",
      "django-filter":"21.1",
      "django-imagekit":"4.1.0",
      "django-import-export":"2.9.0",
      "django-migrations-git-conflicts":"1.0",
      "django-model-utils":"4.3.1",
      "django-modeltranslation":"0.18.9",
      "django-money":"3.0.0",
      "django-multitenant":"3.0.0",
      "django-notifications-hq":"1.7.0",
      "django-ordered-model":"3.6",
      "django-phonenumber-field":"7.0.2",
      "django-pydantic-field":"0.2.3",
      "django-querycount":"0.7.0",
      "django-ratelimit":"4.0.0",
      "django-relativedelta":"1.1.2",
      "django-sendgrid-v5":"1.2.2",
      "django-ses":"2.6.1",
      "django-silk":"5.0.3",
      "django-storages":"1.13.2",
      "django-stubs":"1.12.0",
      "django-stubs-ext":"0.7.0",
      "django-timezone-field":"5.0",
      "djangorestframework":"3.13.1",
      "djangorestframework-simplejwt":"5.2.2",
      "djangorestframework-stubs":"1.6.0",
      "docutils":"0.17.1",
      "dpath":"2.1.5",
      "et-xmlfile":"1.1.0",
      "executing":"1.2.0",
      "filelock":"3.9.0",
      "firebase-admin":"6.1.0",
      "fonttools":"4.38.0",
      "future":"0.18.3",
      "google-api-core":"2.11.0",
      "google-api-python-client":"2.79.0",
      "google-auth":"2.16.1",
      "google-auth-httplib2":"0.1.0",
      "google-cloud-core":"2.3.2",
      "google-cloud-firestore":"2.10.0",
      "google-cloud-storage":"2.7.0",
      "google-crc32c":"1.5.0",
      "google-resumable-media":"2.4.1",
      "googleapis-common-protos":"1.58.0",
      "gprof2dot":"2022.7.29",
      "graphql-core":"3.2.3",
      "grpcio":"1.51.3",
      "grpcio-status":"1.51.3",
      "gunicorn":"20.1.0",
      "html5lib":"1.1",
      "httplib2":"0.21.0",
      "icalendar":"4.0.5",
      "idna":"3.4",
      "imagesize":"1.4.1",
      "iniconfig":"2.0.0",
      "ipykernel":"6.21.2",
      "ipython":"8.10.0",
      "itypes":"1.2.0",
      "jedi":"0.18.2",
      "jinja2":"3.1.2",
      "jmespath":"1.0.1",
      "jsonfield":"3.1.0",
      "jsonpickle":"3.0.1",
      "jupyter-client":"8.0.3",
      "jupyter-core":"5.2.0",
      "kombu":"5.2.4",
      "markdown":"3.4.1",
      "markuppy":"1.14",
      "markupsafe":"2.1.2",
      "matplotlib-inline":"0.1.6",
      "mmk-api":"1.0.0",
      "msgpack":"1.0.4",
      "mypy":"0.931",
      "mypy-boto3-s3":"1.26.62",
      "mypy-boto3-ses":"1.26.0.post1",
      "mypy-boto3-sns":"1.26.69",
      "mypy-boto3-ssm":"1.26.77",
      "mypy-extensions":"1.0.0",
      "nest-asyncio":"1.5.6",
      "odfpy":"1.4.1",
      "openpyxl":"3.1.1",
      "packaging":"23.0",
      "parso":"0.8.3",
      "pathspec":"0.11.0",
      "pdf2image":"1.16.2",
      "pexpect":"4.8.0",
      "phonenumberslite":"8.13.7",
      "pickleshare":"0.7.5",
      "pilkit":"2.0",
      "pillow":"9.4.0",
      "pip":"23.0.1",
      "platformdirs":"3.0.0",
      "pluggy":"1.0.0",
      "pprintpp":"0.4.0",
      "preview-generator":"0.28",
      "prompt-toolkit":"3.0.37",
      "proto-plus":"1.22.2",
      "protobuf":"4.22.0",
      "psutil":"5.9.4",
      "psycopg2-binary":"2.9.5",
      "ptyprocess":"0.7.0",
      "pure-eval":"0.2.2",
      "py":"1.11.0",
      "py-moneyed":"2.0",
      "pyasn1":"0.4.8",
      "pyasn1-modules":"0.2.8",
      "pycodestyle":"2.10.0",
      "pycountry":"19.8.18",
      "pycparser":"2.21",
      "pydantic":"1.10.5",
      "pydantic-yaml":"0.8.1",
      "pydot":"1.4.2",
      "pydyf":"0.5.0",
      "pyexifinfo":"0.4.0",
      "pygments":"2.14.0",
      "pyjwt":"2.6.0",
      "pyopenssl":"22.1.0",
      "pyparsing":"3.0.9",
      "pyphen":"0.13.2",
      "pypng":"0.20220715.0",
      "pytest":"6.2.5",
      "pytest-django":"4.5.2",
      "pytest-mock":"3.10.0",
      "python-crontab":"2.7.1",
      "python-dateutil":"2.8.2",
      "python-google-places":"1.4.1",
      "python-http-client":"3.3.7",
      "python-magic":"0.4.27",
      "python-slugify":"7.0.0",
      "pytz":"2022.7.1",
      "pyyaml":"5.3.1",
      "pyzmq":"25.0.0",
      "qrcode":"7.4.2",
      "requests":"2.28.2",
      "retry":"0.9.2",
      "rich":"12.6.0",
      "rsa":"4.9",
      "ruff":"0.0.225",
      "rules":"3.3",
      "s3transfer":"0.6.0",
      "semver":"2.13.0",
      "sendgrid":"6.9.7",
      "sentry-sdk":"1.22.2",
      "setuptools":"67.4.0",
      "shortuuid":"1.0.1",
      "six":"1.16.0",
      "snowballstemmer":"2.2.0",
      "sphinx":"4.5.0",
      "sphinxcontrib-applehelp":"1.0.4",
      "sphinxcontrib-devhelp":"1.0.2",
      "sphinxcontrib-django2":"1.6",
      "sphinxcontrib-htmlhelp":"2.0.1",
      "sphinxcontrib-jsmath":"1.0.1",
      "sphinxcontrib-qthelp":"1.0.3",
      "sphinxcontrib-serializinghtml":"1.1.5",
      "sqlparse":"0.4.3",
      "stack-data":"0.6.2",
      "starkbank-ecdsa":"2.2.0",
      "strawberry-django-plus":"2.2.0",
      "strawberry-graphql":"0.168.1",
      "strawberry-graphql-django":"0.9",
      "structlog":"21.5.0",
      "swapper":"1.3.0",
      "tablib":"3.3.0",
      "text-unidecode":"1.3",
      "tinycss2":"1.2.1",
      "toml":"0.10.2",
      "tomli":"2.0.1",
      "tornado":"6.2",
      "traitlets":"5.9.0",
      "types-awscrt":"0.16.10",
      "types-deprecated":"1.2.9.1",
      "types-markdown":"3.4.2.5",
      "types-polib":"1.2.0.0",
      "types-python-dateutil":"2.8.19.8",
      "types-pytz":"2022.7.1.2",
      "types-pyyaml":"6.0.12.8",
      "types-requests":"2.28.11.14",
      "types-retry":"0.9.9.2",
      "types-s3transfer":"0.6.0.post5",
      "types-setuptools":"57.4.18",
      "types-six":"1.16.21.6",
      "types-urllib3":"1.26.25.7",
      "typing-extensions":"4.5.0",
      "tzdata":"2022.7",
      "uritemplate":"4.1.1",
      "urllib3":"1.26.14",
      "vine":"5.0.0",
      "wand":"0.6.11",
      "wcwidth":"0.2.6",
      "weasyprint":"57.1",
      "webencodings":"0.5.1",
      "wheel":"0.38.4",
      "whitenoise":"6.3.0",
      "wrapt":"1.14.1",
      "xlrd":"2.0.1",
      "xlwt":"1.3.0",
      "zopfli":"0.2.2"
   },
   "nodestore_insert":1683807310.175774,
   "received":1683807307.196334,
   "request":{
      "url":"http://127.0.0.1:8000/graphql",
      "method":"POST",
      "data":{
         "operationName":"allBookings",
         "query":"query allBookings{\n  allBookings {\n    edges {\n      node {\n        reference\n      }\n    }\n  }\n}"
      },
      "cookies":[
         [
            "__hssrc",
            "1"
         ],
         [
            "__hstc",
            "19301799.b812b31fdf7068d86920c6fc5c265938.1682516581472.1683298423434.1683626849372.5"
         ],
         [
            "csrftoken",
            "[Filtered]"
         ],
         [
            "hubspotutk",
            "b812b31fdf7068d86920c6fc5c265938"
         ],
         [
            "sessionid",
            "[Filtered]"
         ]
      ],
      "headers":[
         [
            "Accept",
            "application/json, multipart/mixed"
         ],
         [
            "Accept-Encoding",
            "gzip, deflate, br"
         ],
         [
            "Accept-Language",
            "en-US,en;q=0.7,pl;q=0.3"
         ],
         [
            "Connection",
            "keep-alive"
         ],
         [
            "Content-Length",
            "147"
         ],
         [
            "Content-Type",
            "application/json"
         ],
         [
            "Host",
            "127.0.0.1:8000"
         ],
         [
            "Origin",
            "http://127.0.0.1:8000"
         ],
         [
            "Referer",
            "http://127.0.0.1:8000/graphql"
         ],
         [
            "Sec-Fetch-Dest",
            "empty"
         ],
         [
            "Sec-Fetch-Mode",
            "cors"
         ],
         [
            "Sec-Fetch-Site",
            "same-origin"
         ],
         [
            "User-Agent",
            "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0"
         ],
         [
            "X-Csrftoken",
            "[Filtered]"
         ],
         [
            "X-foobar-Impersonate",
            "demo@foobar.com"
         ]
      ],
      "env":{
         "REMOTE_ADDR":"127.0.0.1",
         "SERVER_NAME":"6714387b6a2c",
         "SERVER_PORT":"8000"
      },
      "inferred_content_type":"application/json"
   },
   "sdk":{
      "name":"sentry.python.django",
      "version":"1.22.2",
      "integrations":[
         "argv",
         "atexit",
         "boto3",
         "celery",
         "dedupe",
         "django",
         "excepthook",
         "logging",
         "modules",
         "redis",
         "stdlib",
         "threading",
         "tornado"
      ],
      "packages":[
         {
            "name":"pypi:sentry-sdk",
            "version":"1.22.2"
         }
      ]
   },
   "timestamp":1683807307.102306,
   "title":"AttributeError: 'function' object has no attribute '__func__'",
   "transaction":"/graphql",
   "transaction_info":{
      "source":"route"
   },
   "type":"error",
   "user":{
      "id":"3892ac33-5848-42e8-bd70-3f51a0bbee7e",
      "email":"demo@foobar.com",
      "ip_address":"127.0.0.1",
      "username":"demo@foobar.com"
   },
   "version":"7"
}

Any ideas what could be happening? Some monkeypatching conflicts? Things to try or check?

antonpirker commented 1 year ago

Hey @Mapiarz Thanks for reporting this. Yea, it looks like Django Debug Toolbar and Sentry are monkey patching the same functions and when Django Debug Toolbar is "unpatching" something an error is happening.

I put in on our backlog, but this has not a really big priority right now. But we are always happy about PRs when you want to try to fix this!

antonpirker commented 10 months ago

Hey @Mapiarz

Finally had time to look at this. I created a simple Django app with strawberry and django debug toolbar and made some requests to the /graphql endpoint and everything works as expected.

The packege versions I used (only showing relevant ones, no dependencies):

Django==4.2.7
django-debug-toolbar==4.2.0
graphql-core==3.2.3
psycopg==3.1.12
strawberry-graphql==0.212.0
strawberry-graphql-django==0.24.0
sentry-sdk==1.34.0

Can you try to update your Sentry SDK version to the newest ones and also update Django Debug Toolbar? If it is still not working after updating all the libs to the newest versions, please supply a minimal project with that I can reproduce this.

getsantry[bot] commented 9 months ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀