Skip to content

Hierarchy in .secrets.toml overwrites settings in settings.toml #649

@m4rc3l-h3

Description

@m4rc3l-h3

Thanks for the great library and your support!

Describe the bug
Using hierarchy in .secrets.toml overwrites settings in settings.toml.

To Reproduce
Steps to reproduce the behavior:

  1. Having the following folder structure
Project structure
files/testing/settings.toml
files/testing/.secrets.toml
src/main.py
  1. Having the following config files:
Config files

files/testing/settings.toml

[default]
[default.db]
    name="name_default"

and

files/testing/.secrets.toml**

[default]
[default.db]
    password = 'default_password'
  1. Having the following app code:
Code

/src/main.py

from dynaconf import LazySettings

settings = LazySettings(
    environments=True,
    ENV_FOR_DYNACONF="default",
    ENVVAR_PREFIX_FOR_DYNACONF="none",
    load_dotenv=True,
    settings_files="../files/testing/settings.toml;../files/testing/.secrets.toml",
)

print(settings.db)
  1. Executing under the following environment
Execution
$ python3 ./src/main.py

Actual behavior
Print: {'password': 'default_password'}

Expected behavior
Print: {'name': 'name_default', 'password': 'default_password'}

Environment (please complete the following information):

  • OS: Linux 10 (buster)
  • Python: 3.9.1
  • Dynaconf Version: 3.1.5
  • Frameworks in use: none

Additional context
Removing hierarchy from .secrets.toml results in expected behavior:

Changing
files/testing/.secrets.toml

Details
[default]
password = 'default_password'

and

/src/main.py

Details
from dynaconf import LazySettings

settings = LazySettings(
    environments=True,
    ENV_FOR_DYNACONF="default",
    ENVVAR_PREFIX_FOR_DYNACONF="none",
    load_dotenv=True,
    settings_files="../files/testing/settings.toml;../files/testing/.secrets.toml",
)

print(settings.db)
print(settings.password)

Results in the following output:

{'name': 'name_default'}
default_password

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions