{"record":{"id":"10cd819abe61efc4","repo":"zhisheng17/flink-learning","slug":"unrecognized-service-type","errorCode":null,"errorMessage":"Unrecognized service type: {}","messagePattern":"Unrecognized service type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClient.java","lineNumber":386,"sourceCode":"\t\t\t\t\t\t}),\n\t\t\tkubeClientExecutorService);\n\t}\n\n\t/**\n\t * Get the Kubernetes service name.\n\t *\n\t * @param serviceType The service type\n\t * @param clusterId The cluster id\n\t * @return Return the Kubernetes service name if the service type is known.\n\t */\n\tprivate String getServiceName(KubernetesService.ServiceType serviceType, String clusterId) {\n\t\tswitch (serviceType) {\n\t\t\tcase REST_SERVICE:\n\t\t\t\treturn ExternalServiceDecorator.getExternalServiceName(clusterId);\n\t\t\tcase INTERNAL_SERVICE:\n\t\t\t\treturn InternalServiceDecorator.getInternalServiceName(clusterId);\n\t\t\tdefault:\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Unrecognized service type: \" + serviceType.name());\n\t\t}\n\t}\n\n\n\tprivate void setOwnerReference(Deployment deployment, List<HasMetadata> resources) {\n\t\tfinal OwnerReference deploymentOwnerReference = new OwnerReferenceBuilder()\n\t\t\t.withName(deployment.getMetadata().getName())\n\t\t\t.withApiVersion(deployment.getApiVersion())\n\t\t\t.withUid(deployment.getMetadata().getUid())\n\t\t\t.withKind(deployment.getKind())\n\t\t\t.withController(true)\n\t\t\t.withBlockOwnerDeletion(true)\n\t\t\t.build();\n\t\tresources.forEach(resource ->\n\t\t\tresource.getMetadata().setOwnerReferences(Collections.singletonList(deploymentOwnerReference)));\n\t}\n","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClient.java#L368-L404","documentation":"getServiceName() switch over KubernetesConfigOptions.ServiceType has only REST_SERVICE and INTERNAL_SERVICE cases; any other (or future/unmapped) enum value falls into the default branch and throws this IllegalArgumentException.","triggerScenarios":"serviceName(serviceType) or updateServiceTargetPort called with a ServiceType not covered by the switch — practically only a new/renamed enum constant in the flink-kubernetes version not yet handled, or a deserialized enum from a different version.","commonSituations":"Mixing Flink client and server jars of different versions where the ServiceType enum gained a constant; custom extensions of the decorator flow passing an unexpected service type; binary-incompatible shaded classpath.","solutions":["Upgrade or align all Flink Kubernetes dependencies so client and server use the same ServiceType enum.","Check the classpath for duplicate/mismatched flink-kubernetes jars (shade conflicts).","If adding a new service type in a fork, extend the switch to handle it.","Log serviceType.name() at the call site to confirm which constant reaches the switch."],"exampleFix":"// before: switch missing new enum constant\nswitch (serviceType) { case REST_SERVICE: ...; case INTERNAL_SERVICE: ...; default: throw ...; }\n// after: handle or normalize unknown types explicitly\nif (serviceType != REST_SERVICE && serviceType != INTERNAL_SERVICE) {\n    throw new IllegalArgumentException(\"Unsupported service type: \" + serviceType);\n}","handlingStrategy":"type-guard","validationCode":"// pre-check the enum value at boundaries\nif (serviceType == null) throw new IllegalArgumentException(\"serviceType required\");\nSet<String> supported = Set.of(\"REST_SERVICE\", \"INTERNAL_SERVICE\");\nif (!supported.contains(serviceType.name())) throw new IllegalArgumentException(\"Unsupported: \" + serviceType);","typeGuard":"static boolean isKnownServiceType(KubernetesConfigOptions.ServiceType t) {\n    return t == KubernetesConfigOptions.ServiceType.REST_SERVICE\n        || t == KubernetesConfigOptions.ServiceType.INTERNAL_SERVICE;\n}","tryCatchPattern":"try {\n    String name = client.getServiceName(serviceType);\n} catch (IllegalArgumentException e) {\n    // unknown enum constant — likely version skew; fail fast with context\n    throw new IllegalStateException(\"Version skew in ServiceType: \" + e.getMessage(), e);\n}","preventionTips":["Keep all flink-kubernetes jars at identical versions.","Check shaded classpath for duplicate enum classes.","Extend the switch when adding enum constants in forks.","Reject unknown service types at configuration load time."],"tags":["kubernetes","enum","service","argument"],"backgroundTag":"invalid-enum-value","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"}