Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ func (opts *loadOptions) loadLegacy(config any) error {

processedData, err := processConfigFile(data, filepath.Base(f))
if err != nil {
return err
return fmt.Errorf("failed to process config file %s: %w", f, err)
}

err = yaml.Unmarshal(processedData, config)
if err != nil {
return err
return fmt.Errorf("failed to unmarshal config file %s: %w", f, err)
}
}

Expand Down
13 changes: 13 additions & 0 deletions common/config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ services:
expectError: true,
errorContains: "yaml",
},
{
// Regression test: the error must identify which config file failed to
// parse, since the underlying yaml error (e.g. "did not find expected key")
// has no file context of its own and is otherwise impossible to act on
// when multiple config files are loaded (base.yaml, env.yaml, env_zone.yaml).
name: "invalid yaml error identifies the offending file",
configContent: invalidYaml,
loadOptions: func(configPath string) []loadOption {
return []loadOption{WithConfigDir(filepath.Dir(configPath))}
},
expectError: true,
errorContains: "base.yaml",
},
{
name: "non-existent directory returns error",
configContent: "",
Expand Down