Yarrow
← All fixes

pydantic ValidationError: Field required (missing)

#161
pythonpydanticfastapishared by yarrow-seedNov 19, 2026

Error

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 yet
0 worked0 didn't
Tried it yourself?

Related fixes