{"record":{"id":"00e8ae4357e622d7","repo":"quarkusio/quarkus","slug":"mongo-config-is-missing-for-creating-mongo-client","errorCode":null,"errorMessage":"mongo config is missing for creating mongo client.","messagePattern":"mongo config is missing for creating mongo client\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java","lineNumber":320,"sourceCode":"    private static class ServerSettingsBuilder implements Block<ServerSettings.Builder> {\n        public ServerSettingsBuilder(MongoClientConfig config) {\n            this.config = config;\n        }\n\n        private final MongoClientConfig config;\n\n        @Override\n        public void apply(ServerSettings.Builder builder) {\n            if (config.heartbeatFrequency().isPresent()) {\n                builder.heartbeatFrequency((int) config.heartbeatFrequency().get().toMillis(), TimeUnit.MILLISECONDS);\n            }\n        }\n    }\n\n    private MongoClientSettings createMongoConfiguration(final MongoClientConfig config, final String name,\n            final boolean isReactive) {\n        if (config == null) {\n            throw new RuntimeException(\"mongo config is missing for creating mongo client.\");\n        }\n        CodecRegistry defaultCodecRegistry = MongoClientSettings.getDefaultCodecRegistry();\n\n        MongoClientSettings.Builder settings = MongoClientSettings.builder();\n\n        if (isReactive) {\n            switch (config.reactiveTransport()) {\n                case NETTY:\n                    // we supports just NIO for now\n                    if (!vertx.isNativeTransportEnabled()) {\n                        configureNettyTransport(settings);\n                    }\n                    break;\n                case MONGO:\n                    // no-op since this is the default behaviour\n                    break;\n            }\n            reactiveContextProviders.stream().findAny().ifPresent(settings::contextProvider);","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java#L302-L338","documentation":"createMongoConfiguration is a private internal helper that must always receive a MongoClientConfig from the mongoConfig.clients() map; this RuntimeException is a defensive assertion that fires only if the config lookup returned null despite a client being requested.","triggerScenarios":"An internal path resolves a client name that is absent from `quarkus.mongodb.clients` (e.g. extension code requesting a default client when no quarkus.mongodb.* properties exist, or a name mismatch between injector and config).","commonSituations":"No MongoDB connection URL configured at all while code still triggers client creation; a named client referenced but its `quarkus.mongodb.<name>.connection-string` missing; custom extension code calling MongoClients with a stale client name.","solutions":["Set `quarkus.mongodb.connection-string` (default client) or `quarkus.mongodb.<name>.connection-string` (named client)","Check that the client name passed to the lookup matches the configured prefix exactly","Ensure MongoConfigLocation/mongo configuration is loaded before the client is created (don't build clients during early startup phases without config)"],"exampleFix":"// before: missing config\n// (no quarkus.mongodb.* properties)\n// after\nquarkus.mongodb.connection-string=mongodb://localhost:27017","handlingStrategy":"validation","validationCode":"// Ensure required Mongo config is present before startup\nif (!ConfigProvider.getConfig().getPropertyNames().stream()\n        .anyMatch(p -> p.startsWith(\"quarkus.mongodb\"))) {\n    throw new ConfigurationException(\"No quarkus.mongodb.* configuration found\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always define quarkus.mongodb.connection-string or a named client config in every profile","Match client names exactly between injection points and configuration prefixes","Add a startup smoke test that builds all clients in CI"],"tags":["mongodb","configuration","quarkus"],"backgroundTag":"missing-configuration","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"}