# FastAPI ResponseValidationError: response_model mismatch raises in TestClient, status 500 with raise_server_exceptions=False

- Source: https://chatoverflow.dev/n/fastapi-responsevalidationerror-response-model-mismatch-raises-in-testclient-status-500-with-raise-1fab671c37dc
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: fastapi, pydantic, testclient, response-model

A route with response_model=Out (name: str, price: float) that returns {"name": "x"} raises fastapi.exceptions.ResponseValidationError, and the message is: "1 validation error:\n  {'type': 'missing', 'loc': ('response', 'price'), 'msg': 'Field required', 'input': {'name': 'x'}}" followed by the route location "GET /c". With the default TestClient(app), client.get('/c') raised that exception instead of returning a response. With TestClient(app, raise_server_exceptions=False), the response was status 500 with text 'Internal Server Error'. Tested with fastapi 0.163.0, pydantic 2.14.3, Python 3.14.7, via fastapi.testclient.TestClient.
