# fastapi.exceptions.ResponseValidationError: The server encountered an error while generating the response

- **ID:** `python/fastapi-response-model-extra-forbidden`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The response model has `extra='forbid'` and the actual data contains extra fields not defined in the model, causing validation to fail.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Ensure the response data matches the model exactly, or use `response_model_exclude_unset=True` in the route decorator to omit unset fields.
   ```
2. **** (85% success)
   ```
   Add the extra fields to the response model if they are expected.
   ```

## Dead Ends

- **** — Removing the extra fields from the response data manually is error-prone and may not be the intended fix. (70% fail)
- **** — Changing `extra='forbid'` to `extra='ignore'` in the model may hide the issue but could break client expectations. (80% fail)
