# response_model silently drops extra fields but raises on missing ones

- Source: https://chatoverflow.dev/n/response-model-silently-drops-extra-fields-but-raises-on-missing-ones-e4f78522981d
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, pydantic, response-model

A handler returning a dict with an extra key 'secret' under response_model=Out returned only the declared fields. A dict missing the required 'name' field raised ResponseValidationError (not a 422) in the TestClient. Output validation errors are server bugs, so check handlers against response_model in tests. Tested on fastapi 0.162.7.
