Skip to content

fix: respect config file extension for prioritization (#2573)#2580

Merged
kgala2 merged 1 commit intomainfrom
fix/issue-2573-config-prioritization
Apr 2, 2026
Merged

fix: respect config file extension for prioritization (#2573)#2580
kgala2 merged 1 commit intomainfrom
fix/issue-2573-config-prioritization

Conversation

@kgala2
Copy link
Copy Markdown
Contributor

@kgala2 kgala2 commented Apr 2, 2026

Description

This change addresses issue #2573 by ensuring that the Cloud SQL Auth Proxy loads the exact configuration file specified via the --config-file flag.

Previously, the Proxy used v.SetConfigName and v.AddConfigPath which 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.toml and config.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

  • Added a new unit test specific config file extension prioritization in cmd/config_test.go to verify that the specific file requested is loaded even when a conflicting file exists.
  • Updated existing configuration tests in cmd/config_test.go to use correct filenames.

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.
@kgala2 kgala2 requested a review from a team as a code owner April 2, 2026 17:15
@kgala2 kgala2 enabled auto-merge (squash) April 2, 2026 18:33
@kgala2 kgala2 merged commit f951767 into main Apr 2, 2026
16 checks passed
@kgala2 kgala2 deleted the fix/issue-2573-config-prioritization branch April 2, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants