{"record":{"id":"7a51cd66bb42a249","repo":"prestodb/presto","slug":"unparseable-port-number","errorCode":null,"errorMessage":"Unparseable port number: ","messagePattern":"Unparseable port number: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-spi/src/main/java/com/facebook/presto/spi/HostAddress.java","lineNumber":206,"sourceCode":"        else {\n            int colonPos = hostPortString.indexOf(':');\n            if (colonPos >= 0 && hostPortString.indexOf(':', colonPos + 1) == -1) {\n                // Exactly 1 colon.  Split into host:port.\n                host = hostPortString.substring(0, colonPos);\n                portString = hostPortString.substring(colonPos + 1);\n            }\n            else {\n                // 0 or 2+ colons.  Bare hostname or IPv6 literal.\n                host = hostPortString;\n            }\n        }\n\n        int port = NO_PORT;\n        if (portString != null && portString.length() != 0) {\n            // Try to parse the whole port string as a number.\n            // JDK7 accepts leading plus signs. We don't want to.\n            if (portString.startsWith(\"+\")) {\n                throw new IllegalArgumentException(\"Unparseable port number: \" + hostPortString);\n            }\n            try {\n                port = Integer.parseInt(portString);\n            }\n            catch (NumberFormatException e) {\n                throw new IllegalArgumentException(\"Unparseable port number: \" + hostPortString);\n            }\n            if (!isValidPort(port)) {\n                throw new IllegalArgumentException(\"Port number out of range: \" + hostPortString);\n            }\n        }\n\n        return new HostAddress(host, port);\n    }\n\n    public static HostAddress fromUri(URI httpUri)\n    {\n        String host = httpUri.getHost();","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spi/src/main/java/com/facebook/presto/spi/HostAddress.java#L188-L224","documentation":"When fromString finds a port suffix it parses it as a plain decimal integer. A leading '+' is rejected explicitly (JDK7 Integer.parseInt accepts it, but URI authority syntax does not), and any value Integer.parseInt cannot parse raises this error. The message quotes the full hostPortString for diagnosis.","triggerScenarios":"HostAddress.fromString(\"host:+8080\") (leading plus) or fromString(\"host:80 80\"), \"host:8080x\", \"host:0x1F90\", \"host:8_080\" — any port substring that is not pure decimal digits.","commonSituations":"Copy-pasted addresses with typographic or unicode digits; templated configs where the port variable was left empty or contained a placeholder; hand-built strings with stray characters.","solutions":["Remove any leading '+' from the port substring","Ensure the port suffix is pure ASCII digits 0-9","Validate the \"host:port\" string with a regex like ^[^:]+:(\\d+)$ before parsing","Log the offending hostPortString to find the malformed source value"],"exampleFix":"// before\nHostAddress.fromUri(new URI(\"http://host:+8080\"));\n// after\nHostAddress.fromUri(new URI(\"http://host:8080\"));","handlingStrategy":"validation","validationCode":"int idx = hostPort.lastIndexOf(':');\nString portStr = hostPort.substring(idx + 1);\nif (portStr.startsWith(\"+\") || !portStr.matches(\"\\\\d+\")) {\n    throw new IllegalArgumentException(\"Port suffix must be plain digits: \" + hostPort);\n}","typeGuard":null,"tryCatchPattern":"try {\n    addr = HostAddress.fromString(hostPort);\n} catch (IllegalArgumentException e) {\n    throw new IllegalArgumentException(\"Bad host:port value in config: \" + hostPort, e);\n}","preventionTips":["Validate port suffix is pure ASCII digits before parsing","Reject '+' prefixes explicitly","Sanitize copy-pasted values (unicode digits, whitespace, units like '8080/tcp')"],"tags":["spi","network","host-address","parsing","port-validation"],"backgroundTag":"unparseable-port-number","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}