Encountered on ADS 14-beta-33.
While trying to connect to 'local' database on authentication enabled sharded cluster, database connection fails with message 'An error occurred while attempting to connect to your database: 'ok' should never be null...'
(Please refer to the attached screenshot autherror.png).
Steps to reproduce issue:
1) Initiate a sharded cluster as follows (Pls set configurable params as needed):
2) Create a user with username/password = champak/champak that has 'readWrite' privilege on 'test' database.
3) Now try connecting to the 'local' database by providing information as in screenshot autherror.png.
Expected outcome:
a) The user should have been displayed proper error message if auth fails else he should be granted access to the DB.
Actual outcome:
a) A strange error message 'An error occurred while attempting to connect to your database: 'ok' should never be null...' is displayed.
|
201 KB
Actually the MongoDB Server (the mongos instance) sends a "can't use 'local' database through mongos" error as response when trying to use the local database (to see this error, try to authenticate against the local database using MongoShell, then issue any command, e.g. > show collections
), but the Mongo Java Library (the CommandResult.ok()
method) swallows this error and throws the IllegalArgumentException : "'ok' should never be null..." message because it expects that any server response (JSON object) to have an "ok" field.
Unfortunately, it seems that the JSON API for MongoDB Client <--> Server communication is not yet well standardised by the 10gen team. I'll patch the CommandResult.ok() method to handle such scenarios and display the server's response error message.
Verified on ADS 14-beta-74 that now following error message is displayed when trying to connect to 'local' DB on auth enabled sharded cluster:
An error occurred while attempting to connect to your database: can't use 'local' database through mongos
Verified on ADS 14-beta-74 that now following error message is displayed when trying to connect to 'local' DB on auth enabled sharded cluster:
An error occurred while attempting to connect to your database: can't use 'local' database through mongos
Issue #9443 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build ADS 14.0.0-beta-68 (mongo-jdbc 1.2.5) |
No time estimate |
Actually the MongoDB Server (the mongos instance) sends a "can't use 'local' database through mongos" error as response when trying to use the local database (to see this error, try to authenticate against the local database using MongoShell, then issue any command, e.g.
> show collections
), but the Mongo Java Library (theCommandResult.ok()
method) swallows this error and throws the IllegalArgumentException : "'ok' should never be null..." message because it expects that any server response (JSON object) to have an "ok" field.Unfortunately, it seems that the JSON API for MongoDB Client <--> Server communication is not yet well standardised by the 10gen team. I'll patch the CommandResult.ok() method to handle such scenarios and display the server's response error message.