Closed andysnowden closed 3 years ago
Hello @andysnowden!
Thank you for your this issue, it feels weird to have feedback even though the code is very much in alpha ^^'
You are right about this, I have quickly debugged your example and it is an error on my side: whether I find a key in Vault or not I return it in the values dict that Pydantic uses to populate the model, sometimes with a None
value. Pydantic then validates this dict and because None
is not a valid type, it gets angry ^^
I will see to fix this, or you can do a PR if you want :wink: (if you look at vault_settings.py
I try to get the Vault key, log a message if it is not found, but I add it to the dict in any case; this should only happen if we found a value).
Hey @andysnowden!
I fixed the issue and published version 0.4.1a1
on PyPI, try it and tell me how it goes!
The Pydantic
Field
object allows the specification of a default value. However, when used with this plugin the default is ignored and an exception is returned. Is this just a matter of configuration/implementation or does the plugin need to add support for this usecase?So with the above example code if the vault KV pair does not exist you get a
KeyError
exception.However, if the KV pair does exist but is set or even blank it takes that value and ignores the default
Is this just an edge case that is not supported by the plugin? If there was a way to selectively tell the plugin to use defaults if there was a vault exception that would be fine too.