{"record":{"id":"d81f65b97b2dbfd3","repo":"yuliskov/SmartTube","slug":"port-out-of-range-port","errorCode":null,"errorMessage":"port out of range:${port}","messagePattern":"port out of range:(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/liskovsoft/smartyoutubetv2/common/proxy/PasswdInetSocketAddress.java","lineNumber":42,"sourceCode":"    public String getHostString() {\r\n        return mInetSocketAddress.getHostString();\r\n    }\r\n\r\n    public int getPort() {\r\n        return mInetSocketAddress.getPort();\r\n    }\r\n\r\n    public String getUsername() {\r\n        return mUsername;\r\n    }\r\n\r\n    public String getPassword() {\r\n        return mPassword;\r\n    }\r\n\r\n    private static int checkPort(int port) {\r\n        if (port < 0 || port > 0xFFFF)\r\n            throw new IllegalArgumentException(\"port out of range:\" + port);\r\n        return port;\r\n    }\r\n\r\n    private static String checkHost(String hostname) {\r\n        if (hostname == null)\r\n            throw new IllegalArgumentException(\"hostname can't be null\");\r\n        return hostname;\r\n    }\r\n}\r\n","sourceCodeStart":24,"sourceCodeEnd":52,"githubUrl":"https://github.com/yuliskov/SmartTube/blob/3de8d90593e0166f012ca18cc3c7ba45bfd68ac4/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/proxy/PasswdInetSocketAddress.java#L24-L52","documentation":"PasswdInetSocketAddress.createUnresolved validates exactly like java.net.InetSocketAddress: the port must fall in 0..65535, and the offending value is interpolated into the message. -1 is the classic culprit because proxy-string parsing in this codebase degrades a missing or unparsable port to -1 before the check runs.","triggerScenarios":"A proxy spec without a port (user:pass@host) where the parser stored -1; a typed port above 65535 such as 70000; malformed digits like '8080x' parsed to -1 and then passed to createUnresolved.","commonSituations":"Users entering a proxy host without a port in settings; clipboard-imported proxy strings missing the port segment; port field overflow past 65535.","solutions":["Require an explicit port in the proxy settings UI and validate 1..65535 before creating the address","Fix the parsing path so a missing port gets a sensible default (e.g. 3128) or a user-facing error, never -1","Reject out-of-range input early with a clear message instead of letting the constructor throw"],"exampleFix":"// before\nint port = parts.length > 1 ? Integer.parseInt(parts[1]) : -1;\nPasswdInetSocketAddress.createUnresolved(host, port, user, pass);\n\n// after\nint port = parts.length > 1 ? Integer.parseInt(parts[1].trim()) : 3128;\nif (port < 0 || port > 0xFFFF) throw new IllegalArgumentException(\"Bad proxy port: \" + port);\nPasswdInetSocketAddress.createUnresolved(host, port, user, pass);","handlingStrategy":"validation","validationCode":"if (port < 0 || port > 0xFFFF) {\n    throw new IllegalArgumentException(\"Proxy port out of range: \" + port);\n}\nPasswdInetSocketAddress.createUnresolved(host, port, user, pass);","typeGuard":"static boolean isValidPort(int port) {\n    return port >= 0 && port <= 0xFFFF;\n}","tryCatchPattern":null,"preventionTips":["Validate the proxy port field (1..65535) in the UI before saving","Default missing ports to a known value (e.g. 3128), never -1","Parse port digits defensively: trim and catch NumberFormatException"],"tags":["proxy","socket","port","validation","parsing"],"backgroundTag":"port-out-of-range","analyzedSha":"3de8d90593e0166f012ca18cc3c7ba45bfd68ac4","analyzedAt":"2026-08-22T09:19:26.383Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}