feat: add better error handling for middlewares#792
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Probably not needed. Need to check. |
CodSpeed Performance ReportMerging #792 will not alter performanceComparing Summary
|
07f28de to
0b766c9
Compare
| return r; | ||
| } | ||
| Err(e) => { | ||
| let e = e.downcast_ref::<PyErr>().unwrap(); |
There was a problem hiding this comment.
Unsafe error handling that could cause runtime panics. The code assumes all errors from execute_middleware_function will be PyErr type and forces unwrap on the downcast. However, the error could come from other sources like async runtime or type conversion errors. The original code pattern of checking the downcast before unwrapping was safer.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
| response | ||
| } | ||
| Err(e) => { | ||
| let e = e.downcast_ref::<PyErr>().unwrap(); |
There was a problem hiding this comment.
Unsafe error handling that could cause runtime panics. Identical issue to the first occurrence - forcing unwrap on PyErr downcast when the error type is not guaranteed to be PyErr. This could cause the server to crash when handling non-Python errors.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
|
😱 Found 2 issues. Time to roll up your sleeves! 😱 |
5fb08e0 to
0472e42
Compare
Description
This PR fixes #