{"record":{"id":"ba94d6a3f11ce040","repo":"yuliskov/SmartTube","slug":"hostname-can-t-be-null","errorCode":null,"errorMessage":"hostname can't be null","messagePattern":"hostname can't be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/liskovsoft/smartyoutubetv2/common/proxy/PasswdInetSocketAddress.java","lineNumber":48,"sourceCode":"    }\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":30,"sourceCodeEnd":52,"githubUrl":"https://github.com/yuliskov/SmartTube/blob/3de8d90593e0166f012ca18cc3c7ba45bfd68ac4/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/proxy/PasswdInetSocketAddress.java#L30-L52","documentation":"checkHost runs inside PasswdInetSocketAddress.createUnresolved before the address is built: the hostname must be non-null (empty is accepted, mirroring InetSocketAddress.createUnresolved). The throw means the host part of the proxy address never made it into the call — credentials-only input, an '@' with nothing after it, or a parser that returns null on garbage.","triggerScenarios":"Proxy input like 'user:pass@' or 'user:pass' with no host segment; a parsing step that splits incorrectly and assigns null to host before calling createUnresolved.","commonSituations":"Users pasting credentials without the host; malformed proxy strings from settings where the host field was left blank; regex-based extraction failing to match and defaulting to null.","solutions":["Require the host in the proxy settings UI and validate non-empty before creating the address","Fix the string parsing so a missing host produces a user-facing error rather than a null","Trim input and reject blanks early"],"exampleFix":"// before\nPasswdInetSocketAddress.createUnresolved(host /* null when regex missed */, port, user, pass);\n\n// after\nif (host == null || host.trim().isEmpty()) throw new IllegalArgumentException(\"Proxy host required\");\nPasswdInetSocketAddress.createUnresolved(host.trim(), port, user, pass);","handlingStrategy":"validation","validationCode":"if (host == null || host.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"Proxy host is required\");\n}\nPasswdInetSocketAddress.createUnresolved(host.trim(), port, user, pass);","typeGuard":"static boolean hasHost(@Nullable String host) {\n    return host != null && !host.trim().isEmpty();\n}","tryCatchPattern":null,"preventionTips":["Require the host field in proxy settings","Validate the full 'user:pass@host:port' shape with one regex before splitting"],"tags":["proxy","socket","hostname","null-safety","parsing"],"backgroundTag":"invalid-proxy-address","analyzedSha":"3de8d90593e0166f012ca18cc3c7ba45bfd68ac4","analyzedAt":"2026-08-22T09:19:26.383Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}