{"record":{"id":"aaba3b541712fd24","repo":"apache/dolphinscheduler","slug":"host-port-s-illegal","errorCode":null,"errorMessage":"host:port '%s' illegal.","messagePattern":"host:port '(.+?)' illegal\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/BaseDataSourceParamDTO.java","lineNumber":79,"sourceCode":"        }\n        address = address.trim();\n\n        int doubleSlashIndex = address.indexOf(Constants.DOUBLE_SLASH);\n        // trim address like 'jdbc:mysql://host:port/xxx' ends with '/xxx'\n        int slashIndex = address.indexOf(Constants.SLASH, doubleSlashIndex + 2);\n        String hostPortString = slashIndex == -1 ? address.substring(doubleSlashIndex + 2)\n                : address.substring(doubleSlashIndex + 2, slashIndex);\n\n        ArrayList<String> hosts = new ArrayList<>();\n        String portString = null;\n        for (String hostPort : hostPortString.split(Constants.COMMA)) {\n            String[] parts = hostPort.split(Constants.COLON);\n            hosts.add(parts[0]);\n            if (portString == null && parts.length > 1)\n                portString = parts[1];\n        }\n        if (hosts.size() == 0 || portString == null) {\n            throw new IllegalArgumentException(String.format(\"host:port '%s' illegal.\", hostPortString));\n        }\n\n        this.host = String.join(Constants.COMMA, hosts);\n        this.port = Integer.parseInt(portString);\n    }\n\n    /**\n     * Get the datasource type\n     * see{@link DbType}\n     *\n     * @return datasource type code\n     */\n    public abstract DbType getType();\n}\n","sourceCodeStart":61,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/BaseDataSourceParamDTO.java#L61-L94","documentation":"Guard in BaseDataSourceParamDTO.setHostAndPortByAddress: after parsing the jdbc address, it throws when no host could be extracted or no ':port' segment was found — i.e. the host:port part of the address (quoted in the message) lacks a port or is empty/malformed, like 'jdbc:mysql://host' without ':3306'.","triggerScenarios":"Address strings lacking a port (e.g. 'jdbc:mysql://localhost') or lacking hosts (e.g. 'jdbc:mysql://:3306'), or malformed comma-separated host lists.","commonSituations":"Omitting the port for the default, copy-pasting a URL without the port, ZooKeeper-style address variations that the parser cannot handle.","solutions":["Include an explicit port in the address (jdbc:mysql://host:3306)","Check the address format matches what the parser expects (//host1:port,host2:port)","Set host and port fields directly instead of relying on address parsing"],"exampleFix":"// before\nparam.setAddress(\"jdbc:mysql://localhost\");\n// after\nparam.setAddress(\"jdbc:mysql://localhost:3306\");","handlingStrategy":"validation","validationCode":"boolean addrOk = address != null && address.matches(\"^jdbc:[a-z0-9]+://[\\w.,:]+(:\\d+)(/.*)?$\");","typeGuard":null,"tryCatchPattern":"try { dto.setHostAndPortByAddress(address); } catch (IllegalArgumentException e) { /* prompt user for host:port */ }","preventionTips":["Always include the port in the address","Use host:port,host2:port2 format for multi-host","Fall back to explicit host/port fields"],"tags":["validation","parsing","datasource"],"backgroundTag":"invalid-url-format","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}