diff --git a/server/config_check_test.go b/server/config_check_test.go index 63ef54ef..133aaa15 100644 --- a/server/config_check_test.go +++ b/server/config_check_test.go @@ -1129,7 +1129,7 @@ func TestConfigCheck(t *testing.T) { leafnodes { remotes = [ { - url: "tls://connect.ngs.global:7422" + url: "tls://nats:7422" tls { timeout: 0.01 } @@ -1140,6 +1140,30 @@ func TestConfigCheck(t *testing.T) { errorLine: 0, errorPos: 0, }, + { + name: "when leafnode remotes use wrong type", + config: ` + leafnodes { + remotes: { + url: "tls://nats:7422" + } + }`, + err: errors.New(`Expected remotes field to be an array, got map[string]interface {}`), + errorLine: 3, + errorPos: 5, + }, + { + name: "when leafnode remotes url uses wrong type", + config: ` + leafnodes { + remotes: [ + { urls: 1234 } + ] + }`, + err: errors.New(`Expected remote leafnode url to be an array or string, got 1234`), + errorLine: 4, + errorPos: 18, + }, { name: "when setting latency tracking without a system account", config: ` diff --git a/server/opts.go b/server/opts.go index ca005785..c81f7a37 100644 --- a/server/opts.go +++ b/server/opts.go @@ -1455,8 +1455,9 @@ func parseLeafNodes(v interface{}, opts *Options, errors *[]error, warnings *[]e } case "remotes": // Parse the remote options here. - remotes, err := parseRemoteLeafNodes(mv, errors, warnings) + remotes, err := parseRemoteLeafNodes(tk, errors, warnings) if err != nil { + *errors = append(*errors, err) continue } opts.LeafNode.Remotes = remotes @@ -1612,7 +1613,6 @@ func parseLeafUsers(mv interface{}, errors *[]error, warnings *[]error) ([]*User func parseRemoteLeafNodes(v interface{}, errors *[]error, warnings *[]error) ([]*RemoteLeafOpts, error) { var lt token defer convertPanicToErrorList(<, errors) - tk, v := unwrapValue(v, <) ra, ok := v.([]interface{}) if !ok { @@ -1647,6 +1647,9 @@ func parseRemoteLeafNodes(v interface{}, errors *[]error, warnings *[]error) ([] continue } remote.URLs = append(remote.URLs, url) + default: + *errors = append(*errors, &configErr{tk, fmt.Sprintf("Expected remote leafnode url to be an array or string, got %v", v)}) + continue } case "account", "local": remote.LocalAccount = v.(string)