Skip to content
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] Dynaconf does not support null values in yaml #288

Closed
Bahus opened this issue Jan 21, 2020 · 2 comments
Closed

[bug] Dynaconf does not support null values in yaml #288

Bahus opened this issue Jan 21, 2020 · 2 comments
Labels
Milestone

Comments

@Bahus
Copy link

Bahus commented Jan 21, 2020

Describe the bug
If you specify a null value for a variable in a yaml config file and when you try to use this variable you will get "variable does not exists" error.

The same issue should appear when using nulls in vault (since it's a JSON).

To Reproduce
The following python snippet can be used to reproduce the issue:

from dynaconf.base import Settings
settings = Settings()
settings['name'] = 'Hello'
settings['nulled_name'] = None

print(settings['name'])
print(settings['nulled_name'])

The output is:

Hello
Traceback (most recent call last):
  File ".../dynaconf/base.py", line 222, in __getitem__
    raise KeyError("{0} does not exists".format(item))
KeyError: 'nulled_name does not exists'
@Bahus Bahus added the bug label Jan 21, 2020
@lobocode
Copy link

I believe this has something to do with the version of YAML used in dynaconf. The Null value in Yaml can be expressed with null,~. If you use settings ['nulled_name'] = None, you are using Python values ​​to set null to YAML. That is, the syntax is incorrect. However, even using the correct syntax, it will not work. In this case, try to use settings['nulled_name'] = " " https://yaml.org/type/null.html .

@Bahus
Copy link
Author

Bahus commented Jan 27, 2020

@lobocode hi, the "to reproduce" section script shows the problem in the dynaconf core, which in turns affects how dynaconf parses YAML configs (you can reproduce it with value: null or value: ~ in an arbitrary YAML file). I don't really wan't to replace nullable values with spaces, since it may lead to unintended consequences in my application.

@rochacbruno rochacbruno added this to the 2.2.4 milestone Feb 26, 2020
rochacbruno added a commit that referenced this issue Mar 10, 2020
Shortlog of commits since last release:

    Bruno Rocha (8):
          Release version 2.2.3
          Changed text format and fixed tests
          Merge branch '304-ShowDataTypeListCli'
          Fix issue #305 - printing and exporting LazyFormat (#312)
          Fix #288 - Nullable values (#300)
          Default to ruamel.yaml when it is available. (#313)
          Fix #306 - does not defaults to merge, deprecated reset - [Breaking Change] (#315)
          HOTFIX - tox.ini drops 3.5

    Tiago Cordeiro (1):
          Added OSX builds to the Azure Pipeline (#307)

    Vicente Marçal (1):
          Changed CLI list to show data type of the envvars to fix #304

    dependabot-preview[bot] (1):
          Unpinning python-box, removing box_it_up and default_box arguments (#279)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants