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

Config sections are overwritten if values come from multiple sources #706

Open
danny-burrows opened this issue Jan 3, 2025 · 0 comments · May be fixed by #707
Open

Config sections are overwritten if values come from multiple sources #706

danny-burrows opened this issue Jan 3, 2025 · 0 comments · May be fixed by #707

Comments

@danny-burrows
Copy link

I found a (potential) bug that causes entire configuration sections to be overwritten by higher-priority config sources if a subset of config values is set. Issue is cased by calling .update() on the dictionaries in the following lines:

quetz/quetz/config.py

Lines 278 to 298 in 56ab2cf

def init(self, path: str) -> None:
"""Load configurations from various places.
Order of importance for configuration is:
host < user profile < deployment < configuration file from env var < value from
env var
Parameters
----------
deployment_config : str, optional
The configuration stored at deployment level
"""
self.config: Dict[str, Any] = {}
# only try to get config from config file if it exists.
if path:
self.config.update(self._read_config(path))
self.config.update(self._get_environ_config())
self._trigger_update_config()

The fix is to recursively merge the dictionaries instead, favouring values from higher-priority sources such as environment variables.

Minimal Example

For example, if client_id is supplied in <QUETZ-DEPLOYMENT>/config.toml in a section as so:

[github]
client_id = "ABC"

If we pass something like QUETZ_GITHUB_CLIENT_SECRET='abc' through the environment, the entire [github] config section will be overwritten with only the client secret from the environment.

Expected behaviour

I would expect these two values to be merged, this makes sense at least for this use case as specifying secrets through the environment is a common and secure practise.

@danny-burrows danny-burrows linked a pull request Jan 3, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant