Pydantic ValidationError 🐍 Python

pydantic_core._pydantic_core.ValidationError: 1 validation error for Model

Data didn’t match a Pydantic model — a field is missing, has the wrong type, or fails a constraint.

Seen on: Python

Meaning

Each error lists the field location, the problem and the input value. FastAPI turns these into 422 responses for request bodies.

Common causes

  • Missing required field
  • Wrong type (string where int expected, null where not Optional)
  • Extra fields with extra="forbid"
  • Pydantic v1 code on v2 (renamed methods/config)

⚡ Quick fix

  1. Read each error’s loc and msg
  2. Mark optional fields: name: str | None = None
  3. Coerce or validate input upstream
  4. Use model_validate (v2) instead of parse_obj (v1)

Detailed fix by platform

Python

  1. python
    try: User.model_validate(payload)
    except ValidationError as e: print(e.errors())

How to diagnose

  1. Field — loc in each error
  2. Input — The input value shown

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.