-
Notifications
You must be signed in to change notification settings - Fork 572
feat: Remove special cases for error messages #5117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
❌ 14 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
@sentrivana
sentrivana
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks good to me but we should make sure this is what we want because once we release it like this, it'll be tough to change.
How does this work with the old Starlette with the missing __str__? Or did we drop support for it already?
alexander-alderman-webb
commented
Nov 19, 2025
Good point regarding the old Starlette version.
Their HTTPException has a __str__ method since version 0.29 but we support version 0.16 and up.
So our fix to add special handling of a detail property fixed a Starlette and FastAPI specific problem. At the same time, users that happen to have detail properties on their exception lost information, as before #2193 __str__ was used to generate the Sentry exception value.
To keep both worlds happy we could use __repr__ instead of __str__ when
CustomException.__str__ is Exception.__str__; andCustomException.__repr__ is not Exception.__repr__.
Starlette users would see a more meaningful value since __repr__ is added in Starlette 0.12.
Happy to hear other suggestions as well, especially since it'll be hard to change later.
sentrivana
commented
Nov 24, 2025
Hmm so if we detect someone explicitly redefined __repr__ but not __str__, we use __repr__? I'm unsure how often that'd trigger in situations where __str__ would still be more valuable.
Uh oh!
There was an error while loading. Please reload this page.
Description
Always stringify exception values using the
safe_str()method.The special-casing of the
messageanddetailattributes resulted in missing detail. Themessageattribute is a legacy from Python 2, and the detail attribute was returned directly because an old version of Starlette did not implement__str__for some exceptions.Issues
Closes #5050
Reminders
tox -e linters.feat:,fix:,ref:,meta:)