-
Notifications
You must be signed in to change notification settings - Fork 912
GODRIVER-2147 remove session from context in internal CSFLE operations #762
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
Conversation
// Remove the explicit session from the context if one is set. | ||
// The explicit session will be from a different client. | ||
// If an explicit session is set, it is applied after automatic encryption. | ||
ctx = NewSessionContext(ctx, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GODRIVER-2147 describes the error occurring in automatic decryption. The user configured their client with SetBypassAutoEncryption(true)
.
The mcryptClient.client
was never the same as the parent Client
.
Prior to the regression introduced, passing an explicit session to an operation undergoing automatic encryption resulted in a similar error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, but otherwise looks good 👍 . Thanks for the detailed CSFLE tests!
|
||
client, err := mongo.Connect(mtest.Background, clientOpts) | ||
assert.Nil(mt, err, "Connect error: %v", err) | ||
defer client.Disconnect(mtest.Background) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to use mtest.Background
instead of context.Background()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason. This followed suit with tests in client_side_encryption_prose_test.go
: https://github.com/mongodb/mongo-go-driver/blob/22266fc3c85143417f31fb860e9a0cb87ce18b0e/mongo/integration/client_side_encryption_prose_test.go#L139:L139
Summary
Remove the explicit session from the passed context on the
find
,listCollections
, and operations to mongocryptd.Rejected ideas
I considered adding logic to support explicit sessions in
keyRetriever
andcollInfoRetriever
whenClient
andClient#keyVaultClientFLE
refer to the same MongoDB cluster. That could be determined inclient.configureKeyVaultClientFLE
.I see a plausible use case for supporting explicit sessions on the internal
find
andlistCollections
operations. I noted that as part of DRIVERS-1937.But I chose not to. Removing the explicit session is behavior is consistent with other drivers.
If the outcome of the DRIVERS-1937 ticket is to support explicit sessions in
find
andlistCollections
, then I think we can make that change later without harming users.