Skip to content

feat: add better error handling for middlewares#792

Open
sansyrox wants to merge 1 commit intomainfrom
feat/add-better-errors-middlewares
Open

feat: add better error handling for middlewares#792
sansyrox wants to merge 1 commit intomainfrom
feat/add-better-errors-middlewares

Conversation

@sansyrox
Copy link
Member

Description

This PR fixes #

@vercel
Copy link

vercel bot commented Apr 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
robyn ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 12, 2024 10:00pm

@sansyrox
Copy link
Member Author

Probably not needed. Need to check.

@codspeed-hq
Copy link

codspeed-hq bot commented Apr 12, 2024

CodSpeed Performance Report

Merging #792 will not alter performance

Comparing feat/add-better-errors-middlewares (ea602eb) with main (923f876)

Summary

✅ 108 untouched benchmarks

return r;
}
Err(e) => {
let e = e.downcast_ref::<PyErr>().unwrap();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@recurseml
Copy link

recurseml bot commented May 27, 2025

😱 Found 2 issues. Time to roll up your sleeves! 😱

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

Successfully merging this pull request may close these issues.

1 participant