You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pydantic 2.9.2
pydantic_core 2.23.4
pydantic-settings [current main branch so that this fix is present: https://github.com/pydantic/pydantic-settings/pull/400]
In the continuation of #406 I've found that the order of the alias given in AliasChoices change the behaviour, which I believe, shouldn't be the case.
# python test_config.py --sub-model.sub-list=a,b,c
Traceback (most recent call last):
File "./test_config.py", line 30, in<module>
settings = MySettings()
File "/usr/local/lib/python3.10/site-packages/pydantic_settings/main.py", line 155, in __init__
super().__init__(
File "/usr/local/lib/python3.10/site-packages/pydantic/main.py", line 212, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for MySettings
sub_model.sub-list
Input should be a valid list [type=list_type, input_value='["a","b","c"]', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/list_type
In fact, if both of the alias do not include the field name itself (the x), for example:
Versions:
In the continuation of #406 I've found that the order of the alias given in
AliasChoices
change the behaviour, which I believe, shouldn't be the case.Given the following example:
The following works as expected:
But if I change the validation_alias:
Then the following fails
In fact, if both of the alias do not include the field name itself (the
x
), for example:then the error is always thrown.
Not sure if it's in pydantic or pydantic-settings. But I guess this is a bug?
Note this is not a deal breaker since with the workaround of including
x
as the first alias choice mitigates it.The text was updated successfully, but these errors were encountered: