Skip to content

Request::body_json should return 4xx error if body can not be deserialized #494

@jhorstmann

Description

@jhorstmann

Currently the body_json function returns a std::io::Result, which gets converted into a 500 status code later. While this is probably ok for actual io errors, any errors happening during parsing of the json bytes are more likely caused by incorrect data being send by the client and so should result in a 400 Bad Request status code.

See

Ok(serde_json::from_slice(&body_bytes).map_err(|_| std::io::ErrorKind::InvalidData)?)

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