Error2 reports
Fix BadRequestError
in Pydantic
✅ Solution
BadRequestError in pydantic often arises in `model_validator` when the validator receives the raw input data (e.g., a dictionary) instead of the partially validated model instance, especially with `mode='wrap'`. To fix this, ensure your validator's signature correctly expects the validator function and the existing model instance/data as arguments; adjust the validator's logic to handle the input accordingly or, if appropriate, switch to `mode='before'` or `mode='after'` if you need to operate on the raw data before or after validation, respectively. Carefully review the expected input type based on the validator's mode and adapt your code.
Related Issues
Real GitHub issues where developers encountered this error:
Timeline
First reported:May 11, 2026
Last reported:May 11, 2026