{"record":{"id":"ab70216785089594","repo":"zhisheng17/flink-learning","slug":"kubernetes-cluster-id-must-be-no-more-than-char","errorCode":null,"errorMessage":"kubernetes.cluster-id must be no more than {} characters.","messagePattern":"kubernetes\\.cluster-id must be no more than (.+?) characters\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/kubeclient/parameters/AbstractKubernetesParameters.java","lineNumber":72,"sourceCode":"\t}\n\n\t@Override\n\tpublic String getConfigDirectory() {\n\t\tfinal String configDir = flinkConfig.getOptional(DeploymentOptionsInternal.CONF_DIR).orElse(\n\t\t\tflinkConfig.getString(KubernetesConfigOptions.FLINK_CONF_DIR));\n\n\t\tcheckNotNull(configDir);\n\t\treturn configDir;\n\t}\n\n\t@Override\n\tpublic String getClusterId() {\n\t\tfinal String clusterId = flinkConfig.getString(KubernetesConfigOptions.CLUSTER_ID);\n\n\t\tif (StringUtils.isBlank(clusterId)) {\n\t\t\tthrow new IllegalArgumentException(KubernetesConfigOptions.CLUSTER_ID.key() + \" must not be blank.\");\n\t\t} else if (clusterId.length() > Constants.MAXIMUM_CHARACTERS_OF_CLUSTER_ID) {\n\t\t\tthrow new IllegalArgumentException(KubernetesConfigOptions.CLUSTER_ID.key() + \" must be no more than \" +\n\t\t\t\tConstants.MAXIMUM_CHARACTERS_OF_CLUSTER_ID + \" characters.\");\n\t\t}\n\n\t\treturn clusterId;\n\t}\n\n\t@Override\n\tpublic String getNamespace() {\n\t\tfinal String namespace = flinkConfig.getString(KubernetesConfigOptions.NAMESPACE);\n\t\tcheckArgument(!namespace.trim().isEmpty(), \"Invalid \" + KubernetesConfigOptions.NAMESPACE + \".\");\n\n\t\treturn namespace;\n\t}\n\n\t@Override\n\tpublic String getImage() {\n\t\tfinal String containerImage = flinkConfig.getString(KubernetesConfigOptions.CONTAINER_IMAGE);\n\t\tcheckArgument(!containerImage.trim().isEmpty(),","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/kubeclient/parameters/AbstractKubernetesParameters.java#L54-L90","documentation":"getClusterId also enforces a maximum length: if the kubernetes.cluster-id value is longer than Constants.MAXIMUM_CHARACTERS_OF_CLUSTER_ID (63, the Kubernetes label/DNS-name limit) it throws IllegalArgumentException. Kubernetes object names and label values must be at most 63 characters, so longer ids would produce invalid resources.","triggerScenarios":"Setting kubernetes.cluster-id to a string longer than 63 characters, e.g. auto-generated names concatenating app name, environment, timestamp, or a long UUID.","commonSituations":"CI pipelines deriving cluster-id from long branch/job names, teams embedding full deployment names into the cluster id, or templated names exceeding the limit.","solutions":["Shorten kubernetes.cluster-id to 63 characters or fewer.","Hash or truncate the long name (e.g. first 40 chars + short hash) when generating it programmatically.","Add a pre-submit assertion on the length in your deployment script."],"exampleFix":"// before\nclusterId = \"team-prod-flink-session-cluster-us-east-1-a-\" + longUuid; // > 63 chars\n// after\nclusterId = (\"team-prod-flink-\" + Integer.toHexString(longUuid.hashCode())).substring(0, Math.min(63, ...));","handlingStrategy":"validation","validationCode":"String clusterId = flinkConfig.get(KubernetesConfigOptions.CLUSTER_ID);\nif (clusterId != null && clusterId.length() > 63) {\n    clusterId = clusterId.substring(0, 63);\n    flinkConfig.set(KubernetesConfigOptions.CLUSTER_ID, clusterId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    String id = parameters.getClusterId();\n} catch (IllegalArgumentException e) {\n    LOG.error(\"cluster-id too long, shorten to <= 63 chars\");\n}","preventionTips":["Generate cluster ids from short base names plus a hash suffix.","Enforce a <=63-char limit in name-generation utilities.","Test generated names in CI with a length assertion."],"tags":["kubernetes","configuration","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}