-
Notifications
You must be signed in to change notification settings - Fork 51
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
Setting Nested Value Via Environment Variable Removing All Nested Values #152
Comments
Hello! Unfortunately, this is a symptom of a deeper issue having to do with the way that overlays and Here's a script demonstrating the issue without environment variables: import confuse
# Setup.
s = confuse.ConfigSource({'a': {'b': 'c', 'd': 'e'}})
r = confuse.RootView([s])
print(r['a'].get())
# Overriding seems to affect the entire `a` dict.
r['a']['b'].set('c1')
print(r['a']['b'].get())
print(r['a'].get())
# However, `d` is still there.
print(r['a']['d'].get()) The output is:
The upshot is that the other keys in the I totally agree that this behavior is not intuitive, especially for environment variable overrides. It would be great to do something better with this, perhaps with an alternative to |
In addition to iterating over the keys in the view like @sampsyo suggested, you could also use a Template with
When a Without setting environment variables, the output is
With setting the env var (
|
Build: 2.0.0
When I use
set_env()
and only want to change one nested value via environment variables it is removing all the nested values.config.yaml
code
Output: Not setting an environment variable
Output: Setting environment variable
export APP_PARENT_VALUE__NESTED_VALUE1=newValue
Expected Outcome:
The text was updated successfully, but these errors were encountered: