{"record":{"id":"99ce7f1922b4e84c","repo":"quarkusio/quarkus","slug":"invalid-server-address","errorCode":null,"errorMessage":"Invalid server address ","messagePattern":"Invalid server address ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java","lineNumber":514,"sourceCode":"        }\n\n        return addresses.stream()\n                .map(String::trim)\n                .map(new addressParser()).collect(Collectors.toList());\n    }\n\n    private static class addressParser implements Function<String, ServerAddress> {\n        @Override\n        public ServerAddress apply(String address) {\n            String[] segments = COLON_PATTERN.split(address);\n            if (segments.length == 1) {\n                // Host only, default port\n                return new ServerAddress(address);\n            } else if (segments.length == 2) {\n                // Host and port\n                return new ServerAddress(segments[0], Integer.parseInt(segments[1]));\n            } else {\n                throw new IllegalArgumentException(\"Invalid server address \" + address);\n            }\n        }\n    }\n\n    private MongoCredential createMongoCredential(MongoClientConfig config) {\n\n        // get the authsource, or the database from the config, or 'admin' as it is the default auth source in mongo\n        // and null is not allowed\n        String authSource = config.credentials().authSource().orElse(config.database().orElse(\"admin\"));\n        // AuthMechanism\n        AuthenticationMechanism mechanism = null;\n        Optional<String> maybeMechanism = config.credentials().authMechanism();\n        if (maybeMechanism.isPresent()) {\n            mechanism = getAuthenticationMechanism(maybeMechanism.get());\n        }\n\n        UsernamePassword usernamePassword = determineUserNamePassword(config.credentials());\n        if (usernamePassword == null) {","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java#L496-L532","documentation":"Quarkus parses each host in `hosts` into a MongoDB ServerAddress, splitting on ':' to allow host or host:port. If an entry splits into more than 2 segments (or is otherwise malformed), the parser rejects it with this IllegalArgumentException.","triggerScenarios":"Configuring `quarkus.mongodb.hosts` with a value like `host1:27017:extra`, an IPv6 literal without brackets, an empty host entry, or a full connection string pasted into the hosts property.","commonSituations":"Copying a `mongodb://user:pass@host:port/db` URI into the hosts field (the ':' in user:pass creates extra segments); writing bare IPv6 addresses like ::1 instead of [::1]:27017; trailing commas producing empty segments.","solutions":["Use `host` or `host:port` per entry — put credentials/database in `connection-string` instead of `hosts`","Wrap IPv6 addresses in brackets: `[::1]:27017`","Remove stray commas/whitespace from the hosts list","Prefer `quarkus.mongodb.connection-string` entirely for complex setups"],"exampleFix":"// before\nquarkus.mongodb.hosts=user:pass@mongo.example.com:27017\n// after\nquarkus.mongodb.connection-string=mongodb://user:pass@mongo.example.com:27017","handlingStrategy":"validation","validationCode":"// Validate hosts entries before use\nfor (String h : hosts.split(\",\")) {\n    String v = h.trim();\n    if (v.isEmpty()) throw new IllegalArgumentException(\"Empty host entry\");\n    int colon = v.indexOf(':');\n    if (colon != v.lastIndexOf(':') && v.indexOf('[') < 0) {\n        throw new IllegalArgumentException(\"Malformed host (extra ':'): \" + v);\n    }\n    if (colon >= 0 && Integer.parseInt(v.substring(colon + 1, v.indexOf(']') > 0 ? v.length() : v.length())) > 65535) {\n        throw new IllegalArgumentException(\"Invalid port: \" + v);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never paste a full mongodb:// URI into the hosts property","Wrap IPv6 literals in brackets","Use connection-string for anything beyond plain host:port"],"tags":["mongodb","configuration","parsing"],"backgroundTag":"invalid-host-format","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}