{"record":{"id":"1e1a5d48130da399","repo":"nathanmarz/storm","slug":"invalid-port-port","errorCode":null,"errorMessage":"invalid port: ${port}","messagePattern":"invalid port: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"storm-core/src/jvm/backtype/storm/security/auth/ThriftClient.java","lineNumber":54,"sourceCode":"\n    public ThriftClient(Map storm_conf, String host, int port) throws TTransportException {\n        this(storm_conf, host, port, null);\n    }\n\n    public ThriftClient(Map storm_conf, String host, int port, Integer timeout) throws TTransportException {\n        try {\n            //locate login configuration \n            Configuration login_conf = AuthUtils.GetConfiguration(storm_conf);\n\n            //construct a transport plugin\n            ITransportPlugin  transportPlugin = AuthUtils.GetTransportPlugin(storm_conf, login_conf);\n\n            //create a socket with server\n            if(host==null) {\n                throw new IllegalArgumentException(\"host is not set\");\n            }\n            if(port<=0) {\n                throw new IllegalArgumentException(\"invalid port: \"+port);\n            }            \n            TSocket socket = new TSocket(host, port);\n            if(timeout!=null) {\n                socket.setTimeout(timeout);\n            }\n            final TTransport underlyingTransport = socket;\n\n            //establish client-server transport via plugin\n            _transport =  transportPlugin.connect(underlyingTransport, host); \n        } catch (IOException ex) {\n            throw new RuntimeException(ex);\n        }\n        _protocol = null;\n        if (_transport != null)\n            _protocol = new  TBinaryProtocol(_transport);\n    }\n\n    public TTransport transport() {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-core/src/jvm/backtype/storm/security/auth/ThriftClient.java#L36-L72","documentation":"The ThriftClient constructor rejects a port that is <= 0 with IllegalArgumentException(\"invalid port: \"+port). A TCP connection requires a positive port number, so Storm validates the port before creating the TSocket.","triggerScenarios":"Constructing new ThriftClient(storm_conf, login_conf, host, port, ...) with port <= 0 — e.g. port read from an unset config key defaulting to 0, an int uninitialized field, or parsing a blank/invalid port string that yields 0.","commonSituations":"nimbus port config absent so Integer.parseInt of empty value or default 0 is used; copying a config template without filling the port; wiring the wrong config key that holds a non-port number; UI/drpc clients misconfigured with port 0.","solutions":["Set the correct port in the config (e.g. nimbus.thrift.port: 6627) and pass it to the constructor.","Pass a hardcoded or defaulted positive port: int port = portFromConf > 0 ? portFromConf : 6627;","Check the config key you read the port from — a missing key or type mismatch commonly yields 0.","Validate the parsed port before constructing the client."],"exampleFix":"// before\nint port = Integer.parseInt(conf.get(\"nimbus.thrift.port.custom\", \"0\"));\nThriftClient client = new ThriftClient(conf, loginConf, host, port, null, null);\n// after\nint port = Integer.parseInt(conf.getProperty(\"nimbus.thrift.port\"));\nif (port <= 0) throw new IllegalArgumentException(\"port must be positive\");\nThriftClient client = new ThriftClient(conf, loginConf, host, port, null, null);","handlingStrategy":"validation","validationCode":"// Java\nint port = ObjectIntegerCast.getInt(conf.get(Config.NIMBUS_THRIFT_PORT), -1);\nif (port <= 0) throw new IllegalArgumentException(\"invalid nimbus.thrift.port: \" + port + \"; must be > 0\");","typeGuard":"boolean isValidPort(Object p) {\n    return p instanceof Number && ((Number) p).intValue() > 0 && ((Number) p).intValue() <= 65535;\n}","tryCatchPattern":"try {\n    client = new ThriftClient(conf, loginConf, host, port, timeout, asUser);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"invalid port\")) {\n        LOG.error(\"Bad thrift port \" + port + \"; check nimbus.thrift.port in storm.yaml\");\n    }\n    throw e;\n}","preventionTips":["Always set nimbus.thrift.port (typically 6627) in storm.yaml.","Validate ports are in 1..65535 when parsing from config or CLI.","Prefer Config.NIMBUS_THRIFT_PORT constant over string literals to avoid key typos."],"tags":["thrift","client","invalid-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"cdb116e942666973bc4eaa0df098d5bab82739e7","analyzedAt":"2026-09-12T14:30:00.714Z","contentChangedAt":"2026-09-12T14:30:00.714Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}