{"record":{"id":"d35f9a84d5e42860","repo":"OpenNHP/opennhp","slug":"s-servers-d-and-servers-d-share-pubk","errorCode":null,"errorMessage":"%s: [[Servers]][%d] and [[Servers]][%d] share PubKeyBase64 %s — merge them into one cluster with multiple Instances","messagePattern":"(.+?): \\[\\[Servers\\]\\]\\[(.+?)\\] and \\[\\[Servers\\]\\]\\[(.+?)\\] share PubKeyBase64 (.+?) — merge them into one cluster with multiple Instances","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/common/clusterconfig/clusterconfig.go","lineNumber":217,"sourceCode":"\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}\n\t\tseenPK[c.PubKeyBase64] = i\n\t}\n\n\t// Duplicate Name detection — only meaningful when names are\n\t// required (and therefore non-empty). For consumers that leave Name\n\t// optional, blank names are allowed to repeat.\n\tif opts.RequireName {\n\t\tseenName := make(map[string]int, len(clusters))\n\t\tfor i, c := range clusters {\n\t\t\tif prev, ok := seenName[c.Name]; ok {\n\t\t\t\treturn fmt.Errorf(\"%s: [[Servers]][%d] and [[Servers]][%d] share Name %q\",\n\t\t\t\t\tlabel, prev, i, c.Name)\n\t\t\t}\n\t\t\tseenName[c.Name] = i\n\t\t}","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/common/clusterconfig/clusterconfig.go#L199-L235","documentation":"Cluster-config validation error from Normalize's duplicate-pubkey pass: two distinct [[Servers]] entries declare the same PubKeyBase64. Because peers are keyed by public key in device.peerMap, duplicates would race for one slot and cause a mysterious 'wrong instance answered' at runtime, so the collision is surfaced at load time with both indexes and the shared key.","triggerScenarios":"Thrown at nhp/common/clusterconfig/clusterconfig.go:217 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Merge the two entries into a single [[Servers]] block listing each endpoint under [[Servers.Instances]]","Regenerate keys if two genuinely different servers accidentally share a key pair"],"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"}