Preserve exception chains in AsgiFastStream startup#2781
Conversation
|
Considering I'm 99% sure linter will be happy, I'm going to be a little bit lazy and just rely on your CI checks to show linters are happy too, or go down the rabbithole of sorting out the installation issues only when PR checks turn out to fail 😄 (For the record, my global install of ruff is happy too, so the likelihood of version differences with the version declared in |
|
For completeness, the results before and after this change using the minimal reproduction case from #2780 BeforeAfter |
493753c to
54a72b3
Compare
Lancetnik
left a comment
There was a problem hiding this comment.
Thank you a lot for the fix!
Sorry, seems like the linter is not happy 😢 |
`raise ex from None` in AsgiFastStream's `start_lifespan_context` was unconditionally clearing `ex.__cause__`, destroying any exception chain deliberately set with `raise B from A` in an `on_startup` hook. This is now changed to `raise ex from ex.__cause__` so that intentional chains are preserved while the noisy ExceptionGroup wrapper is still suppressed, and a testcase has been added to prevent future regressions. Fixes ag2ai#2780
54a72b3 to
349b3f9
Compare
Well, that's what I get for trying to be lazy. Instant karma 😂 Apologies for the needless extra back-and-forth. Resolving the dependency installation issues proved to be pretty straightforward in the end. Both |
Description
raise ex from Nonein AsgiFastStream'sstart_lifespan_contextwas unconditionally clearingex.__cause__, destroying any exception chain deliberately set withraise B from Ain anon_startuphook.This is now changed to
raise ex from ex.__cause__so that intentional chains are preserved while the noisy ExceptionGroup wrapper is still suppressed, and a testcase has been added to prevent future regressions.Fixes #2780
Type of change
Checklist
just lintshows no errors)just test-coveragejust static-analysis