{"record":{"id":"4291f1959a556596","repo":"cilium/cilium","slug":"must-not-be-more-than-d-characters","errorCode":null,"errorMessage":"must not be more than %d characters","messagePattern":"must not be more than (.+?) characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/clustermesh/types/types.go","lineNumber":72,"sourceCode":"\tif clusterID == ClusterIDMin {\n\t\treturn fmt.Errorf(\"ClusterID %d is reserved\", ClusterIDMin)\n\t}\n\n\tif clusterID > ClusterIDMax {\n\t\treturn fmt.Errorf(\"ClusterID > %d is not supported\", ClusterIDMax)\n\t}\n\n\treturn nil\n}\n\n// ValidateClusterName validates that the given name matches the cluster name specifications.\nfunc ValidateClusterName(name string) error {\n\tif name == \"\" {\n\t\treturn errors.New(\"must not be empty\")\n\t}\n\n\tif len(name) > clusterNameMaxLength {\n\t\treturn fmt.Errorf(\"must not be more than %d characters\", clusterNameMaxLength)\n\t}\n\n\tif !clusterNameRegex.MatchString(name) {\n\t\treturn errors.New(\"must consist of lower case alphanumeric characters and '-', and must start and end with an alphanumeric character\")\n\t}\n\n\treturn nil\n}\n\nfunc RegisterClusterInfoValidator(lc cell.Lifecycle, cinfo ClusterInfo) {\n\tlc.Append(cell.Hook{\n\t\tOnStart: func(cell.HookContext) error {\n\t\t\tif err := cinfo.InitClusterIDMax(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := cinfo.ValidateStrict(); err != nil {\n\t\t\t\treturn err\n\t\t\t}","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/clustermesh/types/types.go#L54-L90","documentation":"ValidateClusterName enforces the cluster naming rules: at most 32 characters, lower-case alphanumerics and '-', starting and ending with an alphanumeric character (DNS-label-like rules required for Kubernetes resource names and clustermesh identity). This specific error fires when the name exceeds the 32-character limit.","triggerScenarios":"Calling ValidateClusterName() (directly, or via validateName/Validate/ValidateStrict) with a name whose byte length is > clusterNameMaxLength (32).","commonSituations":"Using a long cloud-provider-generated name (e.g. a full EKS/GKE cluster ARN or long environment-prefixed name) as --cluster-name.","solutions":["Shorten the cluster name to 32 characters or fewer (use a short alias)","Keep the long name as infrastructure metadata and pass a short sanitized name to --cluster-name","Trim/replace hyphen runs when deriving the name from FQDNs before validation"],"exampleFix":"// before\n--cluster-name=mycompany-production-us-east-1-eks-main\n// after\n--cluster-name=prod-use1-main","handlingStrategy":"validation","validationCode":"const maxLen = 32\nvar nameRe = regexp.MustCompile(`^([a-z0-9][-a-z0-9]*)?[a-z0-9]$`)\nfunc validateNamePre(name string) error {\n    if name == \"\" { return errors.New(\"cluster name must not be empty\") }\n    if len(name) > maxLen { return fmt.Errorf(\"cluster name must be at most %d characters\", maxLen) }\n    if !nameRe.MatchString(name) { return errors.New(\"cluster name must be lowercase alphanumeric/-, starting and ending alphanumeric\") }\n    return nil\n}","typeGuard":"func isValidClusterName(s string) bool {\n    return s != \"\" && len(s) <= 32 && nameRe.MatchString(s)\n}","tryCatchPattern":"if err := types.ValidateClusterName(name); err != nil {\n    return fmt.Errorf(\"invalid --cluster-name %q: %w\", name, err)\n}","preventionTips":["Truncate/alias long infra-generated cluster names to <= 32 lowercase chars","Run ValidateClusterName in config tooling before deploying Cilium","Use only [a-z0-9-] and never start/end the name with a dash"],"tags":["clustermesh","cluster-name","length-validation"],"backgroundTag":"invalid-cluster-name","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}