{"record":{"id":"d8b580e665161870","repo":"quarkusio/quarkus","slug":"invalid-authmechanism","errorCode":null,"errorMessage":"Invalid authMechanism '","messagePattern":"Invalid authMechanism '","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java","lineNumber":594,"sourceCode":"            String user = credentials.get(USER_PROPERTY_NAME);\n            String password = credentials.get(PASSWORD_PROPERTY_NAME);\n            return new UsernamePassword(user, password.toCharArray());\n        } else {\n            String username = config.username().orElse(null);\n            if (username == null) {\n                return null;\n            }\n            char[] password = config.password().map(String::toCharArray).orElse(null);\n            return new UsernamePassword(username, password);\n        }\n    }\n\n    private AuthenticationMechanism getAuthenticationMechanism(String authMechanism) {\n        AuthenticationMechanism mechanism;\n        try {\n            mechanism = AuthenticationMechanism.fromMechanismName(authMechanism.toUpperCase());\n        } catch (IllegalArgumentException e) {\n            throw new IllegalArgumentException(\"Invalid authMechanism '\" + authMechanism + \"'\");\n        }\n        return mechanism;\n    }\n\n    @PreDestroy\n    public void stop() {\n        for (MongoClient client : mongoClients.values()) {\n            if (client != null) {\n                client.close();\n            }\n        }\n        for (ReactiveMongoClient reactive : reactiveMongoClients.values()) {\n            if (reactive != null) {\n                reactive.close();\n            }\n        }\n    }\n","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java#L576-L612","documentation":"Quarkus converts the configured auth-mechanism string via AuthenticationMechanism.fromMechanismName(uppercased). If the name is not a recognized driver mechanism, the resulting IllegalArgumentException is rethrown with this clearer message.","triggerScenarios":"`quarkus.mongodb.credentials.auth-mechanism` set to a misspelled or non-existent name such as `scram-sha258`, `sha256`, or `mongodb-aws-iam`.","commonSituations":"Typos in application.properties; mixing driver enum names with Mongo URI style names; documentation from an older driver version using different casing/spelling.","solutions":["Use one of: SCRAM-SHA-1, SCRAM-SHA-256, MONGODB-X509, GSSAPI, MONGODB-AWS, PLAIN (only where supported)","Remove the auth-mechanism property entirely to let the driver negotiate the default mechanism","Check for whitespace/casing issues; Quarkus uppercases automatically so case itself is fine","Validate the property with a quick startup test after fixing"],"exampleFix":"// before\nquarkus.mongodb.credentials.auth-mechanism=SCRAM-SHA258\n// after\nquarkus.mongodb.credentials.auth-mechanism=SCRAM-SHA-256","handlingStrategy":"validation","validationCode":"List<String> valid = AuthenticationMechanism.values().stream()\n    .map(Enum::name).toList();\nString mech = \"SCRAM-SHA-256\";\nif (!valid.contains(mech.toUpperCase())) {\n    throw new ConfigurationException(\"Invalid auth-mechanism: \" + mech + \"; valid: \" + valid);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy mechanism names directly from driver AuthenticationMechanism enum values","Add a config validation step in CI that parses application.properties values","Avoid free-text mechanisms typed from memory"],"tags":["mongodb","authentication","configuration","validation"],"backgroundTag":"invalid-config-value","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"}