{"record":{"id":"e48cc27957f204dc","repo":"apache/flink","slug":"invalid-port-range","errorCode":null,"errorMessage":"Invalid port range: \"{}\"","messagePattern":"Invalid port range: \"(.+?)\"","errorType":"validation","errorClass":"IllegalConfigurationException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/PortRange.java","lineNumber":48,"sourceCode":"    private final String portRange;\n    private final Iterator<Integer> portsIterator;\n\n    public PortRange(int port) {\n        this(String.valueOf(port));\n    }\n\n    /**\n     * Creates a new port range instance.\n     *\n     * @param portRange given port range string\n     * @throws IllegalConfigurationException if given port range string is invalid\n     */\n    public PortRange(String portRange) {\n        this.portRange = checkNotNull(portRange);\n        try {\n            portsIterator = NetUtils.getPortRangeFromString(portRange);\n        } catch (NumberFormatException e) {\n            throw new IllegalConfigurationException(\"Invalid port range: \\\"\" + portRange + \"\\\"\");\n        }\n    }\n\n    public Iterator<Integer> getPortsIterator() {\n        return portsIterator;\n    }\n\n    @Override\n    public String toString() {\n        return portRange;\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/PortRange.java#L30-L61","documentation":"PortRange's constructor delegates the range string to NetUtils.getPortRangeFromString; if parsing hits a NumberFormatException (non-numeric token), it rethrows as IllegalConfigurationException quoting the whole range. This is the typed wrapper used when port-range configs are bound to PortRange objects. Note it only catches NumberFormatException — range-order and bound-validation errors from NetUtils propagate with their own messages.","triggerScenarios":"Constructing new PortRange(\"abc\"), \"8081-https\", \"9000-\" or any range containing a non-integer token; configs like 'rest.port: rest_port' where a variable was never substituted.","commonSituations":"Unsubstituted template placeholders ('${port}') in YAML; typos; environment-specific configs where the port field got a service name instead of a number.","solutions":["Check the quoted range string in the message and correct it to integer tokens ('8081', '8081-8090').","Ensure templating actually substituted port variables before the config reaches Flink.","Add a config smoke test asserting the port-range string matches \\d+(-\\d+)? patterns."],"exampleFix":"# before\nrest.bind-port: ${PORT_RANGE} # unsubstituted\n\n# after\nrest.bind-port: 8081-8090","handlingStrategy":"validation","validationCode":"static final java.util.regex.Pattern PORT_RANGE = java.util.regex.Pattern.compile(\"^\\\\d+(-\\\\d+)?(,\\\\d+(-\\\\d+)?)*$\");\nif (!PORT_RANGE.matcher(rangeDef.trim()).matches()) { throw new IllegalArgumentException(\"bad port range: \" + rangeDef); }","typeGuard":null,"tryCatchPattern":"catch (IllegalConfigurationException e) { if (e.getMessage().startsWith(\"Invalid port range\")) { /* reject the config/deploy artifact with the quoted value */ } }","preventionTips":["Regex-check port-range strings at config-authoring time.","Verify template variables are substituted before deployment."],"tags":["configuration","ports","validation","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}