Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs discrepancy with FromParam #2880

Open
fenhl opened this issue Oct 27, 2024 Discussed in #2879 · 1 comment
Open

Docs discrepancy with FromParam #2880

fenhl opened this issue Oct 27, 2024 Discussed in #2879 · 1 comment

Comments

@fenhl
Copy link
Contributor

fenhl commented Oct 27, 2024

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

@the10thWiz
Copy link
Collaborator

If you have some time, would you mind opening a PR to update the documentation? I believe that the actual behavior here, forwarding with 422 is the appropriate action.

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

No branches or pull requests

2 participants