-
Notifications
You must be signed in to change notification settings - Fork 569
Closed
Closed
Copy link
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.25.1
Steps to Reproduce
- Create 2 simple FastAPI routes that raise exceptions like this:
@router.get("/http-exception")
async def trigger_http_exception():
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Intentional HTTPException, please ignore",
)
class MyHTTPException(HTTPException):
"""This class should be used to throw our custom HTTPExceptions,
as the base class does not provide the error message to Sentry"""
def __init__(self, status_code: int, message: str):
super().__init__(
status_code=status_code,
detail=message,
)
self.message = message # required to make Sentry display subtitles on issues
@router.get("/http-exception-cause")
async def trigger_http_exception_with_cause():
raise MyHTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
message="Intentional HTTPExceptionWithCause, please ignore",
)- Call the endpoint at
/http-exception - Call the endpoint at
/http-exception-cause - Go to Sentry's issue page, and confirm that only the
MyHTTPExceptionprovides a subtitle for the issue with the error message, and theHTTPExceptiondoes not.
I also contacted Sentry support and they also confirmed this is a bug.
Expected Result
Both exceptions should show the error message as the subtitle in the issue. On FastAPI HTTPExceptions this is called detail.
Actual Result
Only the custom MyHTTPException has the subtitle in Sentry issues.

I debugged printing the event on the before_send function and the event.exception.values[0].value as an empty string for HTTPExceptions:
This is not the case with our custom exceptions, that as a workaround set the message field.
nicolassanmar
Metadata
Metadata
Assignees
Projects
Status
No status
