Skip to content

Docs discrepancy with FromParam #2880

Closed
@fenhl

Description

@fenhl

The FromParam docs say:

If the conversion fails, the incoming request will be forwarded to the next matching route, if any.

Since there are no additional matching routes, this example will result in a 404 error for requests with invalid id values.

However, the actual behavior of such an endpoint when requested with a non-usize parameter is to return 422 Unprocessable Content:

#[rocket::get("/<id>")]
fn hello(id: usize) -> String {
    id.to_string()
}

#[rocket::launch]
async fn launch() -> _ {
    rocket::build()
    .mount("/", rocket::routes![
        hello,
    ])
}

Tested on Rocket commit 3bf9ef0.

Discussed in #2879

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions