{"record":{"id":"7cc7196428175ad3","repo":"quarkusio/quarkus","slug":"config-property-quarkus-mongodb-database-must-be","errorCode":null,"errorMessage":"Config property 'quarkus.mongodb.database' must be defined when no database exist in the connection string","messagePattern":"Config property 'quarkus\\.mongodb\\.database' must be defined when no database exist in the connection string","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"extensions/liquibase/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/LiquibaseMongodbFactory.java","lineNumber":122,"sourceCode":"        if (changeLog.startsWith(\"classpath:\")) {\n            return StringUtil.changePrefix(changeLog, \"classpath:\", \"\");\n        }\n\n        return changeLog;\n    }\n\n    public Liquibase createLiquibase() {\n        try (ResourceAccessor resourceAccessor = resolveResourceAccessor()) {\n            MongoClients mongoClients = Arc.container().instance(MongoClients.class).get();\n            String parsedChangeLog = parseChangeLog(liquibaseMongodbBuildTimeConfig.changeLog());\n            String connectionString = mongoClientConfig.connectionString().orElse(\"mongodb://localhost:27017\");\n            Matcher matcher = HAS_DB.matcher(connectionString);\n            Optional<String> maybeDatabase = mongoClientConfig.database();\n            if (maybeDatabase.isEmpty()) {\n                if (matcher.matches() && !StringUtil.isNullOrEmpty(matcher.group(\"db\"))) {\n                    maybeDatabase = Optional.of(matcher.group(\"db\"));\n                } else {\n                    throw new IllegalArgumentException(\"Config property 'quarkus.mongodb.database' must \" +\n                            \"be defined when no database exist in the connection string\");\n                }\n            }\n            Database database = createDatabase(mongoClients, clientName, maybeDatabase.get());\n            if (liquibaseMongodbConfig.liquibaseCatalogName().isPresent()) {\n                database.setLiquibaseCatalogName(liquibaseMongodbConfig.liquibaseCatalogName().get());\n            }\n            if (liquibaseMongodbConfig.liquibaseSchemaName().isPresent()) {\n                database.setLiquibaseSchemaName(liquibaseMongodbConfig.liquibaseSchemaName().get());\n            }\n            if (liquibaseMongodbConfig.liquibaseTablespaceName().isPresent()) {\n                database.setLiquibaseTablespaceName(liquibaseMongodbConfig.liquibaseTablespaceName().get());\n            }\n            if (liquibaseMongodbConfig.defaultCatalogName().isPresent()) {\n                database.setDefaultCatalogName(liquibaseMongodbConfig.defaultCatalogName().get());\n            }\n            if (liquibaseMongodbConfig.defaultSchemaName().isPresent()) {\n                database.setDefaultSchemaName(liquibaseMongodbConfig.defaultSchemaName().get());","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/liquibase/liquibase-mongodb/runtime/src/main/java/io/quarkus/liquibase/mongodb/LiquibaseMongodbFactory.java#L104-L140","documentation":"LiquibaseMongodbFactory.createLiquibase needs a database name for the Liquibase MongoDB database handle. It first checks the quarkus.mongodb.database config; if absent it tries to extract the database from the connection string via a regex, and if neither exists it throws this IllegalArgumentException. The message is explicit: MongoDB connection strings can be database-less (e.g. mongodb://host:27017), so the database must be configured.","triggerScenarios":"quarkus.liquibase-mongodb.start-actions is enabled, the connection string in quarkus.mongodb.connection-string has no database segment, and quarkus.mongodb.database is not set — LiquibaseMongodbFactory.createLiquibase (invoked from doStartActions at startup) throws.","commonSituations":"Developers configure only mongodb://localhost:27017 without quarkus.mongodb.database; connecting to Atlas with a SRV string lacking the /database part; a named client (quarkus.mongodb.<name>.) where only the default config was filled in; enabling Liquibase MongodbStartActions on an app that never needed a default DB.","solutions":["Set the database in application.properties, e.g. quarkus.mongodb.database=mydb (or quarkus.mongodb.<client-name>.database for a named client)","Alternatively append the database to the connection string: mongodb://user:pass@host:27017/mydb or mongodb+srv://cluster/host/mydb","If multiple clients exist, make sure the config is set for the client Liquibase is targeting, not just the default","Confirm the Liquibase startup actions are intended for that client and that its config block exists"],"exampleFix":"# before\nquarkus.mongodb.connection-string=mongodb://localhost:27017\n# after\nquarkus.mongodb.connection-string=mongodb://localhost:27017\nquarkus.mongodb.database=inventory","handlingStrategy":"validation","validationCode":"// Fail fast at startup if the DB name is neither in config nor in the connection string\nString cs = config.getValue(\"quarkus.mongodb.connection-string\");\nString db = config.getOptionalValue(\"quarkus.mongodb.database\", String.class).orElse(null);\nString dbFromCs = null;\nif (cs != null) {\n    java.net.URI u = java.net.URI.create(cs);\n    String p = u.getPath();\n    if (p != null && p.length() > 1) dbFromCs = p.substring(1);\n}\nif ((db == null || db.isBlank()) && (dbFromCs == null || dbFromCs.isBlank())) {\n    throw new IllegalArgumentException(\"Set quarkus.mongodb.database or append the database to the connection string\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    liquibaseMongodbFactory.createLiquibase();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"quarkus.mongodb.database\")) {\n        // supply the database name or append it to the connection string\n    }\n    throw e;\n}","preventionTips":["Always set quarkus.mongodb.database when using database-less connection strings","Include the database in the connection string (mongodb://host:27017/mydb) as the single source of truth","Check per-client keys (quarkus.mongodb.<name>.database) when using named clients","Smoke-test startup locally with MongodbStartActions enabled before deploying"],"tags":["mongodb","liquibase","configuration","missing-property","startup"],"backgroundTag":"missing-required-config-property","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}