actix-web icon indicating copy to clipboard operation
actix-web copied to clipboard

Default behavior for errors while deserializing body as json

Open tronta opened this issue 5 years ago • 3 comments

Currently there is only a 400 when a correct body is not provided. async fn index(query: web::Json<Parameter>) -> String {

Expected Behavior

An error should be provided as it is done for the query parameters: Body deserialize Json error: invalid type: string "k", expected f32, line: 4, column: 16)) Query: Query deserialize error: missing field first

Current Behavior

Currently only a 400 is provided.

Possible Solution

Steps to Reproduce (for bugs)

implement a handler with web::Json<Parameter> and provide json with missing mandatory fields.

  • Rust Version (I.e, output of rustc -V): web::Json<Parameter>
  • Actix Web Version: 3

tronta avatar Sep 15 '20 20:09 tronta

This would be very useful, at the moment deserialization problems are way too complicated to debug.

Nutomic avatar Jul 02 '21 21:07 Nutomic

Doesn't https://github.com/actix/actix-web/pull/2376 address this issue (although the PR needs to be updated with the recent changes)?

LukeMathWalker avatar Jan 16 '22 15:01 LukeMathWalker

moving this to post-v4 so we can have a play with some ideas through actix-web-lab

robjtede avatar Jan 19 '22 02:01 robjtede