Skip to content

Fix optional default values#19

Open
allixx wants to merge 1 commit into
MasterGroosha:masterfrom
allixx:fix-optional-default-values
Open

Fix optional default values#19
allixx wants to merge 1 commit into
MasterGroosha:masterfrom
allixx:fix-optional-default-values

Conversation

@allixx
Copy link
Copy Markdown

@allixx allixx commented Oct 21, 2025

pydantic 2.11 validator fails when optional configuration parameters are not defined in config file:

pydantic_core._pydantic_core.ValidationError: 3 validation errors for Settings
webhook_domain
  Field required [type=missing, input_value={'bot_token': 'xxxxxxxxxx...nt_confirmation': 'yes'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/missing
webhook_path
  Field required [type=missing, input_value={'bot_token': 'xxxxxxxxxx...nt_confirmation': 'yes'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/missing
custom_bot_api
  Field required [type=missing, input_value={'bot_token': 'xxxxxxxxxx...nt_confirmation': 'yes'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/missing

In pydantic 2.x optional fields must have default value, otherwise they are treated as required. None seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants