telegram-feedback-bot icon indicating copy to clipboard operation
telegram-feedback-bot copied to clipboard

Fix optional default values

Open allixx opened this issue 2 months ago • 0 comments

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.

allixx avatar Oct 21 '25 10:10 allixx