{"record":{"id":"9bafddd3d0cbc1cf","repo":"OpenNHP/opennhp","slug":"s-servers-d-s-has-no-instances","errorCode":null,"errorMessage":"%s: [[Servers]][%d] (%s) has no instances","messagePattern":"(.+?): \\[\\[Servers\\]\\]\\[(.+?)\\] \\((.+?)\\) has no instances","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/common/clusterconfig/clusterconfig.go","lineNumber":188,"sourceCode":"\t\t\t// incomplete migration. Refuse to guess which one the\n\t\t\t// operator meant.\n\t\t\treturn fmt.Errorf(\"%s: [[Servers]][%d] (%s) sets both top-level Ip/Hostname/Port and [[Servers.Instances]]; \"+\n\t\t\t\t\"pick one form — top-level fields are deprecated, prefer Instances\",\n\t\t\t\tlabel, i, c.PubKeyBase64)\n\t\tcase legacy && !hasInstances:\n\t\t\tdeprecate(\"%s: [[Servers]][%d] uses legacy single-server form (Hostname/Ip/Port at top level); \"+\n\t\t\t\t\"migrate to [[Servers.Instances]] in server.toml — auto-upgrading for now\",\n\t\t\t\tlabel, i)\n\t\t\tc.Instances = []InstanceConfig{{\n\t\t\t\tHost:   c.Hostname,\n\t\t\t\tIp:     c.Ip,\n\t\t\t\tPort:   c.Port,\n\t\t\t\tWeight: 1,\n\t\t\t}}\n\t\t\t// Zero the legacy fields so downstream code never sees both.\n\t\t\tc.Hostname, c.Ip, c.Port = \"\", \"\", 0\n\t\tcase !legacy && !hasInstances:\n\t\t\treturn fmt.Errorf(\"%s: [[Servers]][%d] (%s) has no instances\", label, i, c.PubKeyBase64)\n\t\t}\n\n\t\tif err := c.LoadBalance.Validate(); err != nil {\n\t\t\treturn fmt.Errorf(\"%s: [[Servers]][%d] (%s): %w\", label, i, c.PubKeyBase64, err)\n\t\t}\n\t\tc.LoadBalance = c.LoadBalance.Normalize()\n\n\t\tfor j := range c.Instances {\n\t\t\tinst := &c.Instances[j]\n\t\t\tif inst.Host == \"\" && inst.Ip == \"\" {\n\t\t\t\treturn fmt.Errorf(\"%s: [[Servers]][%d] instance #%d: Host and Ip both empty\", label, i, j)\n\t\t\t}\n\t\t\tif inst.Port <= 0 {\n\t\t\t\treturn fmt.Errorf(\"%s: [[Servers]][%d] instance #%d: invalid Port %d\", label, i, j, inst.Port)\n\t\t\t}\n\t\t\tif inst.Weight <= 0 {\n\t\t\t\tinst.Weight = 1\n\t\t\t}","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/common/clusterconfig/clusterconfig.go#L170-L206","documentation":"Cluster-config validation error from Normalize: a [[Servers]] entry has no [[Servers.Instances]] and no legacy top-level address fields either, so the cluster would contain zero reachable endpoints. Entries with legacy fields are auto-upgraded; this error fires only for the genuinely empty case.","triggerScenarios":"Thrown at nhp/common/clusterconfig/clusterconfig.go:188 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add at least one [[Servers.Instances]] block with Host/Ip and Port","Or restore the legacy top-level Hostname/Ip/Port fields to let the auto-upgrade path fill Instances"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}