Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated IsIsMasterDoc function to work with drivers that send IsMaste… #41

Conversation

rdeavilafloqast
Copy link
Contributor

@rdeavilafloqast rdeavilafloqast commented Nov 30, 2021

Issue

This fixes the following issue: #30

Summary

The node.js driver, and potentially other drivers, make a handshake with the isMaster document formatted a little bit differently than what the current code expects. The ismaster|isMaster value is a boolean, instead of a number. This is causing the isMaster command to breach the proxy and reach the server, and when sent with client metadata, causes the server to respond with the error:

MongoServerSelectionError: The client metadata document may only be sent in the first isMaster

Here are examples of different drivers and how their document in this function appear:

node.js

{"ismaster": true,"helloOk": true,"client": {"driver": {"name": "nodejs","version": "4.2.0"},"os": {"type": "Darwin","name": "darwin","architecture": "x64","version": "20.6.0"},"platform": "Node.js v14.15.4, LE (unified)\|Node.js v14.15.4, LE (unified)"},"compression": ["none"],"loadBalanced": false}

MongoDB Shell

{"isMaster": {"$numberInt":"1"},"client": {"application": {"name": "MongoDB Shell"},"driver": {"name": "MongoDB Internal Client","version": "4.4.0"},"os": {"type": "Darwin","name": "Mac OS X","architecture": "x86_64","version": "20.6.0"}}}

PyMongo

{"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo","version": "4.0"},"os": {"type": "Darwin","name": "Darwin","architecture": "x86_64","version": "10.16"},"platform": "CPython 3.9.4.final.0"}}

Changes

This change will make drivers that pass in boolean values for isMaster to be successfully intercepted.

…r documents with 'isMaster' set to a boolean value instead of a number
Copy link
Contributor

@mdehoog mdehoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution 🙌

@mdehoog mdehoog merged commit 7340694 into coinbase:master Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants