diff --git a/config/config.go b/config/config.go index 09eabb041..9a764ace3 100644 --- a/config/config.go +++ b/config/config.go @@ -1017,7 +1017,16 @@ func (v *Variable) ValidateTypeAndDefault() error { // If an explicit type is declared, ensure it is valid if v.DeclaredType != "" { if _, ok := typeStringMap[v.DeclaredType]; !ok { - return fmt.Errorf("Variable '%s' must be of type string, map, or list - '%s' is not a valid type", v.Name, v.DeclaredType) + validTypes := []string{} + for k := range typeStringMap { + validTypes = append(validTypes, k) + } + return fmt.Errorf( + "Variable '%s' type must be one of [%s] - '%s' is not a valid type", + v.Name, + strings.Join(validTypes, ", "), + v.DeclaredType, + ) } } diff --git a/config/loader_test.go b/config/loader_test.go index ace70d90e..a2a2929f2 100644 --- a/config/loader_test.go +++ b/config/loader_test.go @@ -684,7 +684,7 @@ func TestLoadFile_badVariableTypes(t *testing.T) { } errorStr := err.Error() - if !strings.Contains(errorStr, "'bad_type' must be of type string") { + if !strings.Contains(errorStr, "'bad_type' type must be one of") { t.Fatalf("bad: expected error has wrong text: %s", errorStr) } }