Skip to content
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

Open
rmartin16 opened this issue Nov 19, 2024 · 1 comment
Open

to_repr() can leak exceptions with Rich #678

rmartin16 opened this issue Nov 19, 2024 · 1 comment

Comments

@rmartin16
Copy link

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.

@rmartin16
Copy link
Author

Managed to boil down an example, fwiw:

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant