fix: respect config file extension for prioritization (#2573)#2580
Merged
fix: respect config file extension for prioritization (#2573)#2580
Conversation
Ensures that Viper loads the specific configuration file provided via the --config-file flag by using SetConfigFile instead of SetConfigName and AddConfigPath. This prevents filename ambiguity when multiple files with the same base name but different extensions exist in the same directory. Similar to AlloyDB Auth Proxy PR #914.
enocom
approved these changes
Apr 2, 2026
panavenue
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change addresses issue #2573 by ensuring that the Cloud SQL Auth Proxy loads the exact configuration file specified via the
--config-fileflag.Previously, the Proxy used
v.SetConfigNameandv.AddConfigPathwhich caused Viper to search for any file with a matching base name and supported extension in that directory. This led to ambiguous behavior when multiple files with the same base name (e.g.,config.tomlandconfig.json) existed in the same directory, often prioritizing the wrong file extension based on Viper's internal defaults.By using
v.SetConfigFile(c.conf.Filepath), we explicitly specify the file to be loaded, preventing any ambiguity or unintended prioritization.This change is similar to the fix in the AlloyDB Auth Proxy PR #914.
Related Issues
Closes #2573
Testing
specific config file extension prioritizationincmd/config_test.goto verify that the specific file requested is loaded even when a conflicting file exists.cmd/config_test.goto use correct filenames.