{"record":{"id":"2ceded2aa92ebd50","repo":"zhisheng17/flink-learning","slug":"should-be-specified-to-a-fixed-port-do-not-sup","errorCode":null,"errorMessage":"{} should be specified to a fixed port. Do not support a range of ports.","messagePattern":"(.+?) should be specified to a fixed port\\. Do not support a range of ports\\.","errorType":"exception","errorClass":"FlinkRuntimeException","httpStatus":null,"severity":"error","filePath":"flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/utils/KubernetesUtils.java","lineNumber":105,"sourceCode":"\t\t\t\tport.key(),\n\t\t\t\tfallbackPort);\n\t\t}\n\t}\n\n\t/**\n\t * Parse a valid port for the config option. A fixed port is expected, and do not support a range of ports.\n\t *\n\t * @param flinkConfig flink config\n\t * @param port port config option\n\t * @return valid port\n\t */\n\tpublic static Integer parsePort(Configuration flinkConfig, ConfigOption<String> port) {\n\t\tcheckNotNull(flinkConfig.get(port), port.key() + \" should not be null.\");\n\n\t\ttry {\n\t\t\treturn Integer.parseInt(flinkConfig.get(port));\n\t\t} catch (NumberFormatException ex) {\n\t\t\tthrow new FlinkRuntimeException(\n\t\t\t\tport.key() + \" should be specified to a fixed port. Do not support a range of ports.\",\n\t\t\t\tex);\n\t\t}\n\t}\n\n\t/**\n\t * Generate name of the Deployment.\n\t */\n\tpublic static String getDeploymentName(String clusterId) {\n\t\treturn clusterId;\n\t}\n\n\t/**\n\t * Get task manager labels for the current Flink cluster. They could be used to watch the pods status.\n\t *\n\t * @return Task manager labels.\n\t */\n\tpublic static Map<String, String> getTaskManagerLabels(String clusterId) {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/utils/KubernetesUtils.java#L87-L123","documentation":"KubernetesUtils.parsePort reads a string-valued port ConfigOption from the Flink configuration and parses it with Integer.parseInt. Because the option is a String, users can supply a port range like \"8081-8090\"; that fails parsing and is rethrown as this FlinkRuntimeException. Only a single fixed integer port is acceptable.","triggerScenarios":"Setting an exposed/REST/UI/JobManager-RPC port option (e.g. kubernetes.rest-service.exposed.port, rest.port as string) to a range \"8081-8091\", a comma list, or any non-integer text.","commonSituations":"Copying Docker-style -p 8081-8090:8081-8090 range syntax into flink-conf.yaml, or leaving template placeholders that don't parse as integers.","solutions":["Set the port option to a single fixed integer, e.g. rest.port: 8081.","Let Flink pick a free port by removing the option instead of specifying a range.","Strip whitespace/units from the value; ensure only digits are present."],"exampleFix":"// before\nkubernetes.rest-service.exposed.port: 8081-8090\n// after\nkubernetes.rest-service.exposed.port: 8081","handlingStrategy":"validation","validationCode":"String portStr = flinkConfig.get(portOption);\nif (portStr != null && !portStr.trim().matches(\"\\\\d+\")) {\n    throw new IllegalArgumentException(portOption.key() + \" must be a single fixed integer port, got: \" + portStr);\n}","typeGuard":null,"tryCatchPattern":"try {\n    int port = KubernetesUtils.parsePort(flinkConfig, KubernetesConfigOptions.REST_SERVICE_EXPOSED_PORT);\n} catch (FlinkRuntimeException e) {\n    LOG.error(\"Port must be fixed, not a range: {}\", e.getMessage());\n}","preventionTips":["Put single integer values in port config options; drop the option for dynamic ports.","Do not copy Docker -p range syntax into flink-conf.yaml.","Add config linting that rejects non-integer port values."],"tags":["kubernetes","configuration","port"],"backgroundTag":"invalid-config-value","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}