Skip to content

Fix - Array entries duplicated when using Validator with default for computed value#910

Merged
rochacbruno merged 3 commits intodynaconf:masterfrom
pedro-psb:bug/duplicated-entry-from-env
Apr 4, 2023
Merged

Fix - Array entries duplicated when using Validator with default for computed value#910
rochacbruno merged 3 commits intodynaconf:masterfrom
pedro-psb:bug/duplicated-entry-from-env

Conversation

@pedro-psb
Copy link
Copy Markdown
Member

This fixes #905


Just for the records, I'll try to explain what I've understood about the problem, sorry if it is too confusing.

One of the key-point of the problem was that the process of setting the default for the Validator uses tomlfy=True and this causes some side-effect on the default field siblings.

In the last step of recording this value there is a merge_before_set(new, old) function. I would expect that the new data to be merged in the existing data would be only the default value provided in Validation, but all of it's siblings are used too (including list).

Before this merge, parse_conf_data(data, tomlfy=True, ...) is called with 'default' value and all of it's existing siblings, and this makes new and old data to have different version of test_list, one that is "tomlyfied" and the other that is not (the original one).

- when using validator with the default field, list items would get
  duplicated under certain circunstances.
- this avoids an unwanted merge when setting the default for some value.
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 3, 2023

Deploy Preview for dynaconf ready!

Name Link
🔨 Latest commit 5b3be39
🔍 Latest deploy log https://app.netlify.com/sites/dynaconf/deploys/642beadae623360008ae03d6
😎 Deploy Preview https://deploy-preview-910--dynaconf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@rochacbruno rochacbruno merged commit 27a8547 into dynaconf:master Apr 4, 2023
@aqc-carlodri
Copy link
Copy Markdown

Thanks for the fix @pedro-psb!

@pedro-psb pedro-psb deleted the bug/duplicated-entry-from-env branch April 5, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] array entries duplicated with Validator using default for computed value.

3 participants