-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
to_repr()
can leak exceptions with Rich
#678
Comments
Managed to boil down an example, fwiw: # /// script
# dependencies = [
# "structlog>=24.4.0",
# "pydantic",
# "rich",
# ]
# # run this file with "uv run --script script.py"
# ///
import structlog
from pydantic import BaseModel, computed_field
class Model(BaseModel):
a: int
@computed_field
def a_otherwise(self) -> int:
return self.a
def main():
try:
Model(a="")
except Exception as e:
structlog.get_logger().exception("error")
main() |
The exception happens in |
Yeah, here's the traceback:
It looks like rich is trying to repr the error and causes another error? I don't have it in me to debug the combination of Rich and Pydantic but it might be somewhat related to #679 and should be reported to Rich. |
oh and also #655 as Stefan wrote |
Upgraded from v24.2.0 to v24.4.0 and exception logging started raising its own exceptions. Previously, the
repr-error
text would be used; therefore,rich.pretty.traverse()
is hitting the same error as the previous logic and letting the exception leak. It isn't clear to me if Rich should be catching these or structlog (or if we just shouldn't have a few classes that cause this...) but I think it is unexpected for exception logging to start raising itself.The text was updated successfully, but these errors were encountered: