From 0b4b2d827d63e11317e5cb22fccd13bddb6dc457 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Thu, 1 Jul 2021 16:46:45 -0400 Subject: [PATCH 1/2] fix(connection): report more helpful error with unsupported authMechanism in initial handshake --- 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..9c1d86cedaf 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(`authMechanism '${credentials.mechanism}' not supported`)); + } authProvider.prepare(handshakeDoc, authContext, callback); return; } From 354ca3bb9e782889e2dd8bf30d28713db969d244 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Thu, 1 Jul 2021 18:01:02 -0400 Subject: [PATCH 2/2] Update lib/core/connection/connect.js Co-authored-by: Neal Beeken --- lib/core/connection/connect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/connection/connect.js b/lib/core/connection/connect.js index 9c1d86cedaf..191b6c8446e 100644 --- a/lib/core/connection/connect.js +++ b/lib/core/connection/connect.js @@ -180,7 +180,7 @@ function prepareHandshakeDocument(authContext, callback) { const authProvider = AUTH_PROVIDERS[credentials.mechanism]; if (authProvider == null) { - return callback(new MongoError(`authMechanism '${credentials.mechanism}' not supported`)); + return callback(new MongoError(`No AuthProvider for ${credentials.mechanism} defined.`)); } authProvider.prepare(handshakeDoc, authContext, callback); return;