New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] when using a validator with a default for nested data it parses value via toml twice #979
Comments
rochacbruno
added a commit
that referenced
this issue
Aug 16, 2023
3 years ago I made the wrong decision to pass validators defaults to TOML parser. Validator object is created at Python level, or at YAML level where there is no need to use toml as parser. TOML parser must ideally be used only on environment variables where there is no type system available. That said, this PR ensures toml will keep parsing values coming from envvars, but setdefault method will stop passing `tomlfy=True` so the type informed on the validator will be the type set as default value. The only possible breaking change on this is if someone is setting defaults relying on TOML to parse the data, in that case, user will need to manually call `parse_with_toml` on default data. I think that is not a common case, if someone reports it as a broken change, we can provide a new argument `parse_default_with_toml` on the Validator object later.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Execution
$ DYNACONF_GROUP__TEST_LIST="['1','2']" python app.py
expectation:
current behavior
What is happening?
At the end of validators.validate.validate the
Validator("group.something_new", default=5),
is executed and then default value is merged with current data, during that process dynaconf is callingparse_conf_data
passingtomlfy=True
which forces toml to evaluate the existing data again so.Possible solutions:
Change
setdefault
method to usetomlfy=False
Change
parse_with_toml
to avoid doing that transformation.The text was updated successfully, but these errors were encountered: