{"record":{"id":"d6441b08459df405","repo":"quarkusio/quarkus","slug":"invalid-port-number","errorCode":null,"errorMessage":"Invalid port number","messagePattern":"Invalid port number","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusRestClientBuilder.java","lineNumber":181,"sourceCode":"    public RestClientBuilder queryParamStyle(QueryParamStyle queryParamStyle) {\n        this.queryParamStyle = queryParamStyle;\n        return this;\n    }\n\n    @Override\n    public RestClientBuilder header(final String name, final Object value) {\n        headers.add(Objects.requireNonNull(name, \"A header name is required.\"),\n                Objects.requireNonNull(value, \"Value for header is required.\"));\n        return this;\n    }\n\n    @Override\n    public RestClientBuilder proxyAddress(String host, int port) {\n        if (host == null) {\n            throw new IllegalArgumentException(\"proxyHost must not be null\");\n        }\n        if (port <= 0 || port > 65535) {\n            throw new IllegalArgumentException(\"Invalid port number\");\n        }\n        this.proxyHost = host;\n        this.proxyPort = port;\n        return this;\n    }\n\n    @Override\n    public RestClientBuilder baseUrl(URL url) {\n        try {\n            baseURI = url.toURI();\n            return this;\n        } catch (URISyntaxException e) {\n            throw new RuntimeException(e.getMessage());\n        }\n    }\n\n    @Override\n    public RestClientBuilder baseUri(URI uri) {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusRestClientBuilder.java#L163-L199","documentation":"Thrown by QuarkusRestClientBuilder.proxyAddress when the port is outside the valid range 1-65535. Proxy ports must be a valid TCP port, so zero, negative values and values above 65535 are rejected with IllegalArgumentException.","triggerScenarios":"Calling builder.proxyAddress(host, 0), a negative port, or a port parsed from a truncated/garbled config value; port > 65535 from an int overflow of a concatenated string; passing -1 as a 'no proxy' sentinel.","commonSituations":"Using -1 or 0 as a default 'unset' port constant; config property proxy-address missing the port part so the parsed default leaks through; typos like 80800.","solutions":["Pass a valid port in the 1-65535 range (typically 80, 443, 3128, 8080, etc.)","Fix the proxy-address config value to a valid host:port pair","Do not use sentinel values like 0 or -1 to disable the proxy — simply don't call proxyAddress"],"exampleFix":"// before\nbuilder.proxyAddress(\"proxy.corp\", 80800); // IllegalArgumentException: Invalid port number\n// after\nbuilder.proxyAddress(\"proxy.corp\", 8080);","handlingStrategy":"validation","validationCode":"if (port < 1 || port > 65535) {\n    throw new IllegalArgumentException(\"Proxy port out of range: \" + port);\n}","typeGuard":"static boolean isValidPort(int p) { return p > 0 && p <= 65535; }","tryCatchPattern":"try {\n    builder.proxyAddress(host, port);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Invalid port number\")) {\n        log.error(\"Bad proxy port: {}\", port);\n    }\n    throw e;\n}","preventionTips":["Never use 0 or -1 as a 'disabled' sentinel port — omit the proxyAddress call instead","Parse proxy ports with Integer.parseInt and range-check before use","Validate proxy-address host:port config values at startup"],"tags":["rest-client","proxy","configuration","port","illegal-argument"],"backgroundTag":"invalid-proxy-configuration","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}