{"record":{"id":"62b446fd0afbafd3","repo":"temporalio/temporal","slug":"unknown-cluster-name-v-with-given-cluster-initia","errorCode":null,"errorMessage":"Unknown cluster name: %v with given cluster initial failover version map: %v.","messagePattern":"Unknown cluster name: (.+?) with given cluster initial failover version map: (.+?)\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/cluster/metadata.go","lineNumber":279,"sourceCode":"\t\t},\n\t}\n}\n\nfunc (m *metadataImpl) IsGlobalNamespaceEnabled() bool {\n\treturn m.enableGlobalNamespace\n}\n\nfunc (m *metadataImpl) IsMasterCluster() bool {\n\treturn m.masterClusterName == m.currentClusterName\n}\n\nfunc (m *metadataImpl) GetClusterID() int64 {\n\tm.clusterLock.RLock()\n\tdefer m.clusterLock.RUnlock()\n\n\tinfo, ok := m.clusterInfo[m.currentClusterName]\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\n\t\t\t\"Unknown cluster name: %v with given cluster initial failover version map: %v.\",\n\t\t\tm.currentClusterName,\n\t\t\tm.clusterInfo,\n\t\t))\n\t}\n\treturn info.InitialFailoverVersion\n}\n\nfunc (m *metadataImpl) GetNextFailoverVersion(clusterName string, currentFailoverVersion int64) int64 {\n\tm.clusterLock.RLock()\n\tdefer m.clusterLock.RUnlock()\n\n\tinfo, ok := m.clusterInfo[clusterName]\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\n\t\t\t\"Unknown cluster name: %v with given cluster initial failover version map: %v.\",\n\t\t\tclusterName,\n\t\t\tm.clusterInfo,","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/cluster/metadata.go#L261-L297","documentation":"metadataImpl.GetClusterID returns the InitialFailoverVersion of the current cluster. If m.currentClusterName is no longer a key in m.clusterInfo (the map can be mutated by cluster refresh/failover logic), it panics with the current cluster name and the full cluster info map. In a correctly constructed metadata this is unreachable; it guards against internal state drift.","triggerScenarios":"Calling GetClusterID after the cluster info map was refreshed or mutated such that the current cluster entry was removed or the current cluster name changed without a matching map update.","commonSituations":"Cluster metadata refresh pulling a new cluster list that excludes the local cluster; custom/test code swapping currentClusterName on a metadataImpl instance.","solutions":["Ensure the cluster membership refresh source always includes the local cluster","Recover from the panic at the caller, log the reported cluster info map, and reinitialize metadata from config","Check for races on currentClusterName (it is guarded by clusterLock; do not mutate it externally)"],"exampleFix":"// before\ncid := metadata.GetClusterID()\n// after\nfunc safeClusterID(m cluster.Metadata) (id int64, err error) {\n  defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"getClusterID panic: %v\", r) } }()\n  return m.GetClusterID(), nil\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"func safeGetClusterID(m cluster.Metadata) (id int64, err error) {\n  defer func() {\n    if r := recover(); r != nil {\n      err = fmt.Errorf(\"GetClusterID panicked: %v\", r)\n    }\n  }()\n  return m.GetClusterID(), nil\n}","preventionTips":["Never mutate metadataImpl internals directly; use the provided APIs","Guarantee cluster membership refresh always includes the local cluster","Monitor refresh failures so a partially updated cluster map is retried, not abandoned"],"tags":["go","panic","cluster-metadata","invariant"],"backgroundTag":"unknown-cluster-name","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}