Skip to content

Case-Insensitive Lookup Might Fail in Dynaconf 3.10 #814

@sanssecours

Description

@sanssecours

Describe the bug

The case-insensitive lookup of data might fail in Dynaconf 3.10 and Dynaconf 3.11 if the config name contains spaces.

To Reproduce

Steps to reproduce the behavior:

  1. Having the following folder structure

    Project structure
    .
    ├── config.yaml
    └── test.py
    
    0 directories, 2 files
    
  2. Having the following config file:

    Config file

    config.yaml

    ROOT:
      BRANCH NODE:
        LEAF
  3. Having the following app code:

    Code

    test.py

    from pathlib import Path
    
    from dynaconf import Dynaconf
    
    if __name__ == '__main__':
        settings = Dynaconf(
            settings_file=[Path(__file__).parent.joinpath('config.yaml')])
        print(settings.root.branch_node)
  4. Executing under the following environment

    Execution
    python3 test.py

Expected behavior

The command should produce the following output:

LEAF 

and exit with a zero exit code.

Actual behavior

The script fails:

Traceback (most recent call last):
  File "/Users/rene/Downloads/test.py", line 8, in <module>
    print(settings.root.branch_node)
  File "/Users/rene/.pyenv/versions/3.10.6/lib/python3.10/site-packages/dynaconf/utils/boxing.py", line 18, in evaluate
    value = f(dynabox, item, *args, **kwargs)
  File "/Users/rene/.pyenv/versions/3.10.6/lib/python3.10/site-packages/dynaconf/utils/boxing.py", line 41, in __getattr__
    return super().__getattr__(n_item, *args, **kwargs)
  File "/Users/rene/.pyenv/versions/3.10.6/lib/python3.10/site-packages/dynaconf/vendor/box/box.py", line 175, in __getattr__
    raise BoxKeyError(str(E)) from _A
dynaconf.vendor.box.exceptions.BoxKeyError: "'DynaBox' object has no attribute 'branch_node'"

with exit code 1. If I install Dynaconf 3.1.9

pip install dynaconf==3.1.9

everything works as expected.

Environment:

  • OS: macOS 12.6
  • Dynaconf Version: 3.1.11

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions