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

Prioritize explicitly defined config files over magic config files loading #16599

Open
wants to merge 1 commit into
base: compatible
Choose a base branch
from

Conversation

joaosreis
Copy link
Member

@joaosreis joaosreis commented Feb 10, 2025

Reorder the loading of configuration files to ensure that explicitly specified files via command-line arguments or environment variables take precedence over magic config files, otherwise, these will never be picked up when magic config files exist.

For example, running mina daemon --config-file /mina/sandbox.json ... will result in this loading order:
["/var/lib/coda/config_46a78df1.json","/root/.mina-config/daemon.json","/mina/sandbox.json"]
By applying this fix, the loading order will change to:
["/mina/sandbox.json","/var/lib/coda/config_46a78df1.json","/root/.mina-config/daemon.json"]

@joaosreis joaosreis requested a review from a team as a code owner February 10, 2025 12:12
@joaosreis joaosreis changed the title Prioritize existing config files over magic config files loading Prioritize explicitly defined config files over magic config files loading Feb 10, 2025
@joaosreis
Copy link
Member Author

!ci-build-me

@martyall
Copy link
Member

martyall commented Feb 10, 2025

So when this list of files gets processed into a configuration value, it will apply the head of the list as a base layer and for each subsequent file it will use the values in that file to override what it has found so far (ie its a left fold).

in your printed example of status quo, this is the order you would want if you expect your sandbox file to override something.

is there a particular field that you are finding that this is not happening for / something else weird is happening ?

@joaosreis
Copy link
Member Author

@martyall ah, I missed that part where each layer will override the previous. Was it always the case or did this change recently?

The scenario where we noticed problems is when we want to completely disregard the built-in network configuration (e.g. when launching a test sandbox network). What would be the best way to employ this?

@martyall
Copy link
Member

martyall commented Feb 10, 2025

As a stop-gap, what happens if you just remove "/var/lib/coda/config_46a78df1.json" ? There are a few places where this file is searched for (depends on system and how you installed), but if you don't see it appear in this logged list then it's not being used.

@martyall ah, I missed that part where each layer will override the previous. Was it always the case or did this change recently?

AFAIK this was always the case for the mina daemon, but not uniform behavior across the entire cli. Can I ask what cli command you are executing ?

@mrmr1993
Copy link
Member

@joaosreis it sounds like you may be running into this

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 this pull request may close these issues.

3 participants