{"record":{"id":"ef0199ea8a3b24dc","repo":"HMCL-dev/HMCL","slug":"host-cannot-be-blank","errorCode":null,"errorMessage":"Host cannot be blank","messagePattern":"Host cannot be blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/game/ProxyOption.java","lineNumber":44,"sourceCode":"record Http(@NotNull String host, int port, @Nullable String username,\n            @Nullable String password) implements ProxyOption {\n    public Http {\n        if (StringUtils.isBlank(host)) {\n            throw new IllegalArgumentException(\"Host cannot be blank\");\n        }\n        if (port < 0 || port > 0xFFFF) {\n            throw new IllegalArgumentException(\"Illegal port: \" + port);\n        }\n    }\n}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/game/ProxyOption.java#L26-L62","documentation":"Compact-constructor guard on the Http proxy record: a blank host string is rejected at construction because an HTTP proxy without a host is meaningless. This is a generic argument validation, not tied to a specific input source.","triggerScenarios":"Calling new ProxyOption.Http(null/\"\"/\" \", port, ...) or deserializing a settings JSON with an empty proxy host into an Http record.","commonSituations":"User enabled 'use proxy' in launcher settings but left the host field empty, config migration lost the host value.","solutions":["Supply a non-blank host string (hostname or IP) when constructing Http","Fix the saved settings file so proxy.host is populated","Disable proxy mode in settings if no proxy is needed"],"exampleFix":"// before\nnew ProxyOption.Http(\"\", 8080, null, null)\n// after\nnew ProxyOption.Http(\"127.0.0.1\", 8080, null, null)","handlingStrategy":"validation","validationCode":"if (host == null || host.isBlank())\n    throw new IllegalArgumentException(\"Proxy host must be set before enabling proxy\");","typeGuard":"static boolean validHttpProxy(String host, int port) {\n    return host != null && !host.isBlank() && port >= 0 && port <= 0xFFFF;\n}","tryCatchPattern":"try {\n    option = new ProxyOption.Http(host, port, user, pass);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Host cannot be blank\")) {\n        // prompt user for host or disable proxy\n    } else throw e;\n}","preventionTips":["Validate settings UI fields before persisting","Treat 'proxy enabled' as requiring host+port","Guard against empty strings from config imports"],"tags":["proxy","config","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}