Skip to content

Commit 5cb30dc

Browse files
Ajit Pratap Singhclaude
authored andcommitted
fix: address PR #133 review feedback
- Fix SA4010 lint error in LoadFromFiles() by renaming unused 'errs' to 'triedPaths' and including tried paths in the error message for better debugging - Add documentation comment to mergeInto() explaining the known limitation where boolean fields only merge when true, preventing explicit false override via environment variables 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2b9b347 commit 5cb30dc

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

pkg/config/loader.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func LoadFromFiles(searchPaths []string) (*Config, error) {
6565
return nil, fmt.Errorf("no search paths provided")
6666
}
6767

68-
var errs []error
68+
var triedPaths []string
6969
for _, path := range searchPaths {
7070
config, err := LoadFromFile(path)
7171
if err == nil {
@@ -74,16 +74,16 @@ func LoadFromFiles(searchPaths []string) (*Config, error) {
7474

7575
// Continue trying other paths if file doesn't exist
7676
if errors.Is(err, os.ErrNotExist) {
77-
errs = append(errs, fmt.Errorf("%s: not found", path))
77+
triedPaths = append(triedPaths, path)
7878
continue
7979
}
8080

8181
// If it's not a "file not found" error, it's a real error - return immediately
8282
return nil, fmt.Errorf("failed to load config from %s: %w", path, err)
8383
}
8484

85-
// If we get here, no config file was found
86-
return nil, fmt.Errorf("no config file found in search paths")
85+
// If we get here, no config file was found - include tried paths in error
86+
return nil, fmt.Errorf("no config file found in search paths: tried %v", triedPaths)
8787
}
8888

8989
// LoadFromEnvironment loads configuration from environment variables.
@@ -257,7 +257,13 @@ func Merge(configs ...*Config) *Config {
257257
return result
258258
}
259259

260-
// mergeInto merges src into dst, with non-zero values from src taking precedence
260+
// mergeInto merges src into dst, with non-zero values from src taking precedence.
261+
//
262+
// NOTE: Boolean fields are only merged when true. This is a known limitation that
263+
// prevents setting booleans to false via environment variables to override a config
264+
// file that has them set to true. A proper fix would require using *bool pointers
265+
// for all boolean fields to distinguish between "not set" and "explicitly set to false".
266+
// See: https://github.com/ajitpratap0/GoSQLX/issues for tracking issue.
261267
func mergeInto(dst, src *Config) {
262268
// Merge Format
263269
if src.Format.Indent != 0 {

0 commit comments

Comments
 (0)