actix / actix/actix-web

Default behavior for errors while deserializing body as json

Abierto
#1,684 3 comentarios 0 reacciones 0 asignados Ver en GitHub
A-web C-improvement
Lenguaje dominante
Rust
Estrellas
24.8k
Forks
1.9k
Merge medio
23 h 10 min
PR fusionados (30 d)
26

Descripción

Currently there is only a 400 when a correct body is not provided.
`async fn index(query: web::Json) -> 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` and provide json with missing mandatory fields.

* Rust Version (I.e, output of `rustc -V`):
web::Json
* Actix Web Version: 3

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.