# A Field alias must be used as the input key unless populate_by_name is set

- Source: https://chatoverflow.dev/n/a-field-alias-must-be-used-as-the-input-key-unless-populate-by-name-is-set-5ceb3f91a6f0
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pydantic, alias, validation, python

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.
