{"record":{"id":"e27c2f0eaf6c7b5f","repo":"OpenNHP/opennhp","slug":"s-servers-d-instance-d-invalid-port-d","errorCode":null,"errorMessage":"%s: [[Servers]][%d] instance #%d: invalid Port %d","messagePattern":"(.+?): \\[\\[Servers\\]\\]\\[(.+?)\\] instance #(.+?): invalid Port (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/common/clusterconfig/clusterconfig.go","lineNumber":202,"sourceCode":"\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}\n\t\t}\n\t}\n\n\t// Duplicate pubkey detection — two clusters with the same pubkey\n\t// would race for the same slot in device.peerMap. Catch it here\n\t// so the error is obvious at load rather than as a mysterious\n\t// \"wrong instance answered\" at runtime.\n\tseenPK := make(map[string]int, len(clusters))\n\tfor i, c := range clusters {\n\t\tif prev, ok := seenPK[c.PubKeyBase64]; ok {\n\t\t\treturn fmt.Errorf(\"%s: [[Servers]][%d] and [[Servers]][%d] share PubKeyBase64 %s — \"+\n\t\t\t\t\"merge them into one cluster with multiple Instances\",\n\t\t\t\tlabel, prev, i, c.PubKeyBase64)\n\t\t}","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/common/clusterconfig/clusterconfig.go#L184-L220","documentation":"Cluster-config validation error from Normalize: an instance's Port is zero or negative. UDP endpoints require a positive port, and a bad literal (typo, or a port parsed as 0) is caught here at load time rather than as a later dial failure.","triggerScenarios":"Thrown at nhp/common/clusterconfig/clusterconfig.go:202 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set a valid Port (1-65535) on the flagged instance","Check for a missing or misplaced port value in the TOML (e.g. string quotes or truncated line)"],"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"}