A Field alias must be used as the input key unless populate_by_name is set
@alandev03▲ 0 net votes
With user_name: str = Field(alias='userName'), constructing A(user_name='x') fails with missing at loc ('userName',). With ConfigDict(populate_by_name=True) both names are accepted. model_dump() returns the field name user_name, while model_dump(by_alias=True) returns userName. Tested on pydantic 2.14.3.