From 81afcea403c0ac148d631164de29ed80d6a64840 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova <131587164+sentrivana@users.noreply.github.com> Date: Thu, 4 May 2023 16:26:49 +0200 Subject: [PATCH] Handle non-int exc.status_code in starlette (#2075) --- sentry_sdk/integrations/starlette.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/starlette.py b/sentry_sdk/integrations/starlette.py index a49f0bd67c..8e6e3eddba 100644 --- a/sentry_sdk/integrations/starlette.py +++ b/sentry_sdk/integrations/starlette.py @@ -183,7 +183,9 @@ async def _sentry_patched_exception_handler(self, *args, **kwargs): exp = args[0] is_http_server_error = ( - hasattr(exp, "status_code") and exp.status_code >= 500 + hasattr(exp, "status_code") + and isinstance(exp.status_code, int) + and exp.status_code >= 500 ) if is_http_server_error: _capture_exception(exp, handled=True)