-
-
Notifications
You must be signed in to change notification settings - Fork 318
[bug] Dynamic variables are evaluated before environment variables populate values #690
Copy link
Copy link
Closed
Labels
LazyIssueRelated to lazy evaluation such as @format etc...Related to lazy evaluation such as @format etc...bug
Description
Describe the bug
When using dynamic variables, we have noticed that they receive the value set in the settings file(s) and are not updated when those referenced settings are overridden by an environment variable.
To Reproduce
Steps to reproduce the behavior:
my_settings.yaml
SERVER:
VERSION:
RELEASE: "6.10"
SNAP: 22
DEPLOY_WORKFLOW: "deploy-sat-jenkins"
DEPLOY_ARGUMENTS:
deploy_sat_version: "@format {this.server.version.release}"
deploy_snap_version: "@format {this.server.version.snap}"
deploy_rhel_version: '7'my_app.py
from dynaconf import Dynaconf
settings = Dynaconf(
envvar_prefix="MYAPP",
core_loaders=["YAML"],
settings_file="my_settings.yaml",
)loading my_app in ipython without environment variable
ipython -i my_app.py
...
In [1]: settings.server.deploy_arguments
Out[1]: <Box: {'deploy_sat_version': '6.10', 'deploy_snap_version': '22', 'deploy_rhel_version': '7'}>
loading my_app in ipython *with( environment variable. notice how the non-dynamic setting is correctly reflecting the value of the environment variable.
MYAPP_SERVER__VERSION__RELEASE="7.2" ipython -i my_app.py
...
In [1]: settings.server.deploy_arguments
Out[1]: <Box: {'deploy_sat_version': '6.10', 'deploy_snap_version': '22', 'deploy_rhel_version': '7'}>
In [2]: settings.server.version.release
Out[2]: 7.2
Expected behavior
The dynamic variable should be evaluated after environment variables populate settings. This will allow for people to use both in conjunction with one another.
Environment (please complete the following information):
- OS: Fedora 35
- Python: 3.9.7
- Dynaconf Version: 3.1.7
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
LazyIssueRelated to lazy evaluation such as @format etc...Related to lazy evaluation such as @format etc...bug