Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improve mongo output handling
This PR contains multiple changes to improve stability of parsing
mongo
output:changes
printjson
toJSON.stringify
to avoid internal typesIn many cases
printjson
is adding internal types (ObjectId
, etc) to the output, which results in an invalid JSON that is not parseable by ruby.For example,
printjson(db.isMaster())
prints something like this:adds logic to extract error object from a corrupted output
Currently, the handling of exceptions is broken because the existing logic is expecting something parseable in the output, but it's not a valid JSON even after sanitization:
Because of this, replica set provider (that relies on an error data) can't detect that the host is online and fails to properly initialize the replica set.
I've added code that attempts to extract an object in case an output is not a valid JSON.
adds check for error code when detecting failed authorization
The existing logic relies on an error message that potentially may change (because of i18n, etc), which may break it in a long run. I've added a check for a error code name, that is less likely to change.