-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
- I have looked for existing issues (including closed) about this
Bug Report
Version
0.8.8
Platform
25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:07:05 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6020 arm64
Crates
axum-macros
Description
#[derive(FromRequest)]
#[from_request(rejection(MyError))]
pub struct Args {
#[from_request(via(Path))]
something: String,
#[from_request(via(Json))]
request: Option<T>
}What I expect: for the optional request field, I get a Some(T) only if a valid JSON body is provided. If it is invalid, it should cause a JsonRejection with the From<JsonRejection> for MyError impl.
What is happening: the expanded version is using FromRequest and .ok() to convert a JsonRejection into None.
What I think should happen: optional field should require the extractor to implement OptionalFromRequest, and use that.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels