From 3ce148d8fb37faea1ee056f6e9331e5282e65cd0 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Fri, 2 Jul 2021 11:18:43 -0400 Subject: [PATCH] fix(NODE-3397): report more helpful error with unsupported authMechanism in initial handshake (#2876) --- lib/core/connection/connect.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/core/connection/connect.js b/lib/core/connection/connect.js index bd10535466e..191b6c8446e 100644 --- a/lib/core/connection/connect.js +++ b/lib/core/connection/connect.js @@ -179,6 +179,9 @@ function prepareHandshakeDocument(authContext, callback) { } const authProvider = AUTH_PROVIDERS[credentials.mechanism]; + if (authProvider == null) { + return callback(new MongoError(`No AuthProvider for ${credentials.mechanism} defined.`)); + } authProvider.prepare(handshakeDoc, authContext, callback); return; }