Skip to content

fix(fullstack): don't panic on incomplete request bodies - #5803

Open
cestercian wants to merge 1 commit into
DioxusLabs:mainfrom
cestercian:cursor/fix-incomplete-body-panic-9ee8
Open

fix(fullstack): don't panic on incomplete request bodies#5803
cestercian wants to merge 1 commit into
DioxusLabs:mainfrom
cestercian:cursor/fix-incomplete-body-panic-9ee8

Conversation

@cestercian

Copy link
Copy Markdown

Summary

Incomplete client bodies can fail Bytes::from_request in production. The one-arg ExtractRequest path was unwrapping that error, which panics the server (FailedToBufferBody).

Change

Bubble the rejection the same way header extraction already does:

let bytes = Bytes::from_request(request, &())
    .await
    .map_err(|e| e.into_response())?;

No anyhow. Sibling extractors (msgpack / cbor / postcard) already used ?.

Test

Unit test drives extract_axum with an erroring body and asserts 400 Bad Request instead of a panic.

cargo test -p dioxus-fullstack --lib
cargo test -p dioxus-fullstack --features server --lib
cargo clippy -p dioxus-fullstack --lib --tests --all-features -- -D warnings

Fixes #5018

Incomplete request bodies can fail Bytes::from_request in production.
Return the rejection as an HTTP response instead of panicking.

Co-authored-by: Cestercian <yashafaid@gmail.com>
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.

Weird error in production "FailedToBufferBody(UnknownBodyError)" in magic.rs

2 participants