{"id":1012,"hash":"436767be3caa5348cbd07d794edb295641c1ab679d7726f0201fc9791ed20575","pattern":"Pydantic returns &#39;field required (type=value_error.missing)&#39; on an Optional field with a custom model","full_message":"I'm trying to build a custom field in Fastapi-users pydantic schema as follows:\n\nclass UserRead(schemas.BaseUser[uuid.UUID]):\n    twitter_account: Optional['TwitterAccount']\n\nOn UserRead validation Pydantic returns\n\nValidationError: 1 validation error for UserRead\ntwitter_account\n  Field required [type=missing, input_value={}, input_type=dict]\n\non every field in 'TwitterAccount' schema.update_forward_refs() is called at the end.\n\nTwitterAccount itself has required fields and making them optional isn't an acceptable workaround. I notices I could make Optional[List['TwitterAccount']] and it will work, but that's a bit silly.","ecosystem":"pypi","package_name":"fastapi","package_version":null,"solution":"Optional is a bit misleading here. What it means technically means is that twitter_account can be a TwitterAccount or None, but it is still a required argument. To make it truly optional (as in, it doesn't have to be provided), you must provide a default:\n\nclass UserRead(schemas.BaseUser[uuid.UUID]):\n    twitter_account: Optional['TwitterAccount'] = None","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/74907839/pydantic-returns-field-required-type-value-error-missing-on-an-optional-fiel","votes":21,"created_at":"2026-04-19T04:52:10.776605+00:00","updated_at":"2026-04-19T04:52:10.776605+00:00"}