{"record":{"id":"27c8407f459c929b","repo":"temporalio/temporal","slug":"current-cluster-name-is-empty","errorCode":null,"errorMessage":"Current cluster name is empty","messagePattern":"Current cluster name is empty","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"common/cluster/metadata.go","lineNumber":150,"sourceCode":"\t}\n)\n\nfunc NewMetadata(\n\tenableGlobalNamespace bool,\n\tfailoverVersionIncrement int64,\n\tmasterClusterName string,\n\tcurrentClusterName string,\n\tclusterInfo map[string]ClusterInformation,\n\tclusterMetadataStore persistence.ClusterMetadataManager,\n\trefreshDuration dynamicconfig.DurationPropertyFn,\n\tlogger log.Logger,\n) Metadata {\n\tif len(clusterInfo) == 0 {\n\t\tpanic(\"Empty cluster information\")\n\t} else if len(masterClusterName) == 0 {\n\t\tpanic(\"Master cluster name is empty\")\n\t} else if len(currentClusterName) == 0 {\n\t\tpanic(\"Current cluster name is empty\")\n\t} else if failoverVersionIncrement == 0 || failoverVersionIncrement > math.MaxInt32 {\n\t\tpanic(\"Version increment <= 0 or > 2147483647\")\n\t}\n\n\tversionToClusterName, err := updateVersionToClusterName(clusterInfo, failoverVersionIncrement)\n\tif err != nil {\n\t\t// nolint:forbidigo // matches the other startup-config panics in this constructor\n\t\tpanic(err.Error())\n\t}\n\tif _, ok := clusterInfo[currentClusterName]; !ok {\n\t\tpanic(\"Current cluster is not specified in cluster info\")\n\t}\n\tif _, ok := clusterInfo[masterClusterName]; !ok {\n\t\tpanic(\"Master cluster is not specified in cluster info\")\n\t}\n\n\tcopyClusterInfo := make(map[string]ClusterInformation)\n\tmaps.Copy(copyClusterInfo, clusterInfo)","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/cluster/metadata.go#L132-L168","documentation":"NewMetadata validates its configuration at construction time and panics if currentClusterName is empty. The metadata API requires a non-empty current cluster name because it is used to look up cluster info, compute cluster IDs, and decide replication behavior. This is a fail-fast startup invariant, not a runtime error.","triggerScenarios":"Calling cluster.NewMetadata(clusterInfo, masterClusterName, \"\", failoverVersionIncrement, ...) or NewMetadataFromConfig with a config file where the currentClusterName field is set to \"\" or missing.","commonSituations":"Empty or mis-rendered temporal cluster config (e.g. config template env var for cluster name not set), copying a multi-cluster config template and deleting the current-cluster entry, or a test harness passing an empty string literal.","solutions":["Set the current cluster name explicitly, e.g. cluster.NewMetadata(clusterInfo, \"active\", \"active\", failoverVersionIncrement, nil)","Check the temporal config template/binding so currentClusterName resolves to a non-empty value before constructing metadata","Call NewMetadataForTest in tests, which supplies a valid default current cluster name"],"exampleFix":"// before\nmd := cluster.NewMetadata(clusterInfo, \"master\", \"\", failoverVersionIncrement, nil, nil)\n// after\nmd := cluster.NewMetadata(clusterInfo, \"master\", \"current-cluster-name\", failoverVersionIncrement, nil, nil)","handlingStrategy":"validation","validationCode":"if currentClusterName == \"\" {\n  return fmt.Errorf(\"currentClusterName must be non-empty before constructing cluster metadata\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate all cluster config fields (names, increment) before calling NewMetadata","Use config templates with required-field checks so empty cluster names fail at config load","In tests, use NewMetadataForTest to get valid defaults"],"tags":["go","panic","configuration","startup"],"backgroundTag":"missing-config-value","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}