Closed merren-fx closed 6 months ago
Thanks @merren-fx for reporting this.
Extracting data from env variables for nested model is not completed and probably is not working for all the cases. I've added a fix for your use case in https://github.com/pydantic/pydantic-settings/pull/261
It would be great if you can test it.
Hey @hramezani #261 seems to fix the issue I mentioned.
But while we are on the topic: is this the expected behavior:
env.set('sub_dict', '"bar": { }')
env.set('sub_dict', '{"bar": { }}')
If not I am happy to contribute.
Thanks @merren-fx for checking.
The first one does not work because '"bar": { }'
is not a valid json and for the same reason the second one is working
Hey all, I am experiencing a (to me) unexpected be behavior when parsing properties of type dict from env-vars.
When trying to set a dictionary value directly using after setting is using a json-encoded object in a env variable an error is thrown:
My pydantic versions:
Minimal example:
When
SUB_DICT__FOO__SUBFIELD
andSUB_DICT__FOO
are swapped the example code works. Is this really the expected behavior ?