{"record":{"id":"76ae6d86ff4cc880","repo":"apache/pulsar","slug":"kubernetes-only-admits-lower-case-and-numbers-jo","errorCode":null,"errorMessage":"Kubernetes only admits lower case and numbers. (jobName=%s)","messagePattern":"Kubernetes only admits lower case and numbers\\. \\(jobName=(.+?)\\)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java","lineNumber":1168,"sourceCode":"            return jobName;\n        }\n        // toValidPodName may cause naming collisions, add a short hash here to avoid it\n        final String shortHash = DigestUtils.sha1Hex(jobNameBase).toLowerCase().substring(0, 8);\n        return convertedJobName + \"-\" + shortHash;\n    }\n    @VisibleForTesting\n    String getServiceUrl(String jobName, String jobNamespace, int instanceId) {\n        String suffix = isNotBlank(kubernetesServiceDomainSuffix) ? kubernetesServiceDomainSuffix : \"svc.cluster.local\";\n        return String.format(\"%s-%d.%s.%s.%s\", jobName, instanceId, jobName, jobNamespace, suffix);\n    }\n    public static void doChecks(FunctionDetails functionDetails, String overridenJobName) {\n        final String jobName = createJobName(functionDetails, overridenJobName);\n        if (!jobName.equals(jobName.toLowerCase())) {\n            throw new RuntimeException(\"Kubernetes does not allow upper case jobNames.\");\n        }\n        final Matcher matcher = VALID_POD_NAME_REGEX.matcher(jobName);\n        if (!matcher.matches()) {\n            throw new RuntimeException(\"Kubernetes only admits lower case and numbers. \"\n                    + \"(jobName=\" + jobName + \")\");\n        }\n        if (jobName.length() > maxJobNameSize) {\n            throw new RuntimeException(\"Kubernetes job name size should be less than \" + maxJobNameSize);\n        }\n    }\n}\n","sourceCodeStart":1150,"sourceCodeEnd":1176,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java#L1150-L1176","documentation":"doChecks() validates the job name against VALID_POD_NAME_REGEX (RFC-1123 DNS label: lowercase alphanumerics and '-', must start/end alphanumeric). A name failing this pattern throws RuntimeException naming the offending jobName. Kubernetes rejects any pod/statefulset/service name violating this, so it fails early.","triggerScenarios":"The composed job name contains invalid characters (underscores, dots, uppercase, leading/trailing '-', or is empty) from function tenant/namespace/name or the overridden job name.","commonSituations":"Function names with underscores (\"my_func\") or dots; names starting with a dash; overly long names (next check > maxJobNameSize); names with special characters from templating.","solutions":["Rename the function to use only lowercase letters, numbers, and '-', starting and ending alphanumeric.","Replace underscores/dots with hyphens in tenant/namespace/function names.","If using a custom job name override, sanitize it to a valid RFC-1123 DNS label."],"exampleFix":"// before\nfunctions create --name my_func.v2 ...\n// after\nfunctions create --name my-func-v2 ...","handlingStrategy":"validation","validationCode":"Pattern RFC1123 = Pattern.compile(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$\");\nString jobName = tenant + \"-\" + namespace + \"-\" + functionName;\nif (!RFC1123.matcher(jobName).matches() || jobName.length() > 63) {\n    throw new IllegalArgumentException(\"Job name is not a valid RFC-1123 DNS label: \" + jobName);\n}","typeGuard":"static boolean isValidDnsLabel(String s) {\n    return s != null && s.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$\") && s.length() <= 63;\n}","tryCatchPattern":"try {\n    functions.create(request);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"only admits lower case and numbers\")) {\n        log.error(\"Replace invalid characters (underscores, dots) with hyphens: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Use only [a-z0-9-] in names, starting/ending with alphanumeric","Never use underscores or dots in function names","Keep total composed job name under maxJobNameSize","Sanitize templated/generated names before submission"],"tags":["kubernetes","functions-runtime","naming","validation"],"backgroundTag":"invalid-kubernetes-resource-name","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}