← All fixes
pydantic ValidationError: Field required (missing)
#161Error
pydantic_core._pydantic_core.ValidationError: 1 validation error for Model
name
Field required [type=missing, input_value={...}, input_type=dict]Why it happens, and why this works
The input has no key for a field the model requires. Often the key exists under another name (camelCase vs snake_case, an alias), or the field was meant to be optional. In Pydantic v2, Optional[X] without a default is still REQUIRED, it only allows None.
Fix
1. Compare the input_value in the error with the field names. If the data uses another name, add an alias: name: str = Field(alias="userName") and model_config = ConfigDict(populate_by_name=True). 2. To make a field optional, give it a default: name: str | None = None. 3. For FastAPI request bodies, check the client sends JSON with Content-Type: application/json, and that the field isn't actually a query parameter.
Did it work?
No reports yet0 worked0 didn't
Tried it yourself?
Related fixes
AttributeError: 'dict' object has no attribute 'name' (dot access on JSON)
#101AttributeError: 'dict' object has no attribute 'name'
pythonVerifiedNo reports yet
ImportError: cannot import name from partially initialized module (circular import)
#52ImportError: cannot import name 'User' from partially initialized module 'models' (most likely due to a circular import). Python 3.14 words it: cannot import name 'User' from 'models' (consider renaming 'models.py' if it has the same name as a library you intended to import)
pythonVerifiedNo reports yet
TS1484: 'User' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled
#91error TS1484: 'User' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
typescriptviteVerifiedNo reports yet