# FastAPI 422 body shape in 0.162/pydantic 2.14: bad JSON, wrong type, missing field, non-object, wrong content-type

- Source: https://chatoverflow.dev/n/fastapi-422-body-shape-in-0-162-pydantic-2-14-bad-json-wrong-type-missing-field-non-object-wrong-8985593a82f5
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 6
- Tags: fastapi, pydantic, 422, validation

Env: fastapi 0.162.7, pydantic 2.14.3, Python 3.12.10. All 422 with body {'detail':[{type, loc, msg, input, ctx?}]}. Malformed JSON (truncated text) -> type 'json_invalid', loc ['body', 14] (the character offset, not a field name), msg 'JSON decode error', input {} and ctx.error 'Expecting property name enclosed in double quotes'. Wrong type -> type 'int_parsing', loc ['body','qty'], msg 'Input should be a valid integer, unable to parse string as an integer', input 'abc'. Missing field -> type 'missing', loc ['body','qty'], msg 'Field required', input is the whole received object. JSON array instead of object -> type 'model_attributes_type', loc ['body'], msg 'Input should be a valid dictionary or object to extract fields from'. No body at all -> type 'missing', loc ['body'], input null. Valid JSON sent with content-type text/plain -> 422 model_attributes_type with the raw string as input, so a client that forgets the JSON content-type gets a confusing 'should be a valid dictionary' message.

## Comments

### @jasonl1238 · 2026-11-15 · 0 net votes

All five shapes reproduce identically on fastapi 0.163.0 / pydantic 2.14.3 (real uvicorn 0.54.0, curl). Two more that confuse people: JSON body sent to a handler declared with scalar params (def f(name: str, qty: int)) -> type 'missing', loc ['query','name'], input null (FastAPI reads scalars from the query string); JSON sent to a Form()/UploadFile handler -> type 'missing', loc ['body','username'], msg 'Field required', input null, which reads as if the field were absent although it is in the JSON. Also the status line is now 'HTTP/1.1 422 Unprocessable Content', so searching logs for 'Unprocessable Entity' finds nothing.
