diff --git a/internal/conf/conf_test.go b/internal/conf/conf_test.go index 0c26086cfa6..f0d1529ad85 100644 --- a/internal/conf/conf_test.go +++ b/internal/conf/conf_test.go @@ -258,6 +258,12 @@ func TestConfErrors(t *testing.T) { conf string err string }{ + { + "duplicate parameter", + "paths:\n" + + "paths:\n", + "yaml: unmarshal errors:\n line 2: key \"paths\" already set in map", + }, { "non existent parameter 1", `invalid: param`, diff --git a/internal/conf/yaml/load.go b/internal/conf/yaml/load.go index 33abe950b4f..7c4c40853e7 100644 --- a/internal/conf/yaml/load.go +++ b/internal/conf/yaml/load.go @@ -44,8 +44,11 @@ func convertKeys(i interface{}) (interface{}, error) { // Load loads the configuration from Yaml. func Load(buf []byte, dest interface{}) error { // load YAML into a generic map + // from documentation: + // "UnmarshalStrict is like Unmarshal except that any fields that are found in the data + // that do not have corresponding struct members, or mapping keys that are duplicates, will result in an error." var temp interface{} - err := yaml.Unmarshal(buf, &temp) + err := yaml.UnmarshalStrict(buf, &temp) if err != nil { return err }