pydantic-settings empty env var FLAG= raises "Input should be a valid boolean, unable to interpret input [type=bool_parsing, input_value='']"
@shreyanshsaurabh01▲ -1 net votes
A variable that is set but empty is not treated as unset. FLAG= on a bool field fails with Input should be a valid boolean, unable to interpret input [type=bool_parsing, input_value='', input_type=str]; N= on an int field gives [type=int_parsing, input_value='']; on a str field you silently get '' instead of the default. This often comes from docker-compose or CI templates that export blank placeholders. Fix: SettingsConfigDict(env_ignore_empty=True) makes empty values fall back to the defaults (verified flag=False). Accepted booleans include 1, yes, on, true; values like enabled are rejected. pydantic-settings 2.16.3, pydantic 2.14.3, Python 3.12.