-
Notifications
You must be signed in to change notification settings - Fork 562
Closed
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.39.0
Steps to Reproduce
- Enable litestar sentry sdk integration
- Throw error and is catched by the sentry sdk
- JWT authentication breaks
Error in JWT autentication, after an exception thrown and catched by the litestar sentry sdk integration:
Traceback (most recent call last):
File "litestar/middleware/_internal/exceptions/middleware.py", line 158, in __call__
await self.app(scope, receive, capture_response_started)
File "litestar/_asgi/asgi_router.py", line 100, in __call__
await asgi_app(scope, receive, send)
File "litestar/middleware/authentication.py", line 87, in __call__
auth_result = await self.authenticate_request(ASGIConnection(scope))
File "litestar/security/jwt/middleware.py", line 267, in authenticate_request
encoded_token = auth_header.partition(" ")[-1]
AttributeError: 'AnnotatedValue' object has no attribute 'partition'
I suspect the sentry sdk replaces some values AnnotatedValue
and this leads to an error in the JWT auth of the litestar framework here:
auth_header = connection.headers.get(self.auth_header) or connection.cookies.get(self.auth_cookie_key)
if not auth_header:
raise NotAuthorizedException("No JWT token found in request header or cookies")
encoded_token = auth_header.partition(" ")[-1]
return await self.authenticate_token(encoded_token=encoded_token, connection=connection)
The litestar framework suggests this is a bug that has to be fixed in sentry sdk:
litestar-org/litestar#3853
Expected Result
Sentry SDK integration does not break JWT authentication middleware.
No exception for an AnnotatedValue
is thrown.
Actual Result
Sentry SDK for litestar breaks the JWT authentication middleware.
Metadata
Metadata
Assignees
Projects
Status
No status