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

feat(deps): bump mongosh, driver to latest COMPASS-9056 #6774

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
449 changes: 223 additions & 226 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/compass-aggregations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"hadron-document": "^8.8.4",
"hadron-type-checker": "^7.4.4",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-collection-model": "^5.25.4",
"mongodb-data-service": "^22.25.4",
"mongodb-database-model": "^2.25.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-connections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"compass-preferences-model": "^2.33.4",
"hadron-app-registry": "^9.4.4",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-build-info": "^1.7.2",
"mongodb-connection-string-url": "^3.0.1",
"mongodb-data-service": "^22.25.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"hadron-build": "^25.7.4",
"lodash": "^4.17.21",
"mocha": "^10.2.0",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-build-info": "^1.7.2",
"mongodb-connection-string-url": "^3.0.1",
"mongodb-log-writer": "^2.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-explain-plan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"d3-hierarchy": "^3.1.2",
"hadron-app-registry": "^9.4.4",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"react": "^17.0.2",
"react-redux": "^8.1.3",
"redux": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-generative-ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
"@mongodb-js/compass-logging": "^1.6.4",
"@mongodb-js/compass-utils": "^0.8.4",
"bson": "^6.10.3",
"mongodb": "^6.14.1",
"compass-preferences-model": "^2.33.4",
"hadron-app-registry": "^9.4.4",
"mongodb": "^6.13.1",
"mongodb-schema": "^12.4.0",
"react": "^17.0.2",
"react-redux": "^8.1.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-import-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"hadron-document": "^8.8.4",
"hadron-ipc": "^3.4.4",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-data-service": "^22.25.4",
"mongodb-ns": "^2.4.2",
"mongodb-query-parser": "^4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-indexes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"compass-preferences-model": "^2.33.4",
"hadron-app-registry": "^9.4.4",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-collection-model": "^5.25.4",
"mongodb-data-service": "^22.25.4",
"mongodb-query-parser": "^4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-query-bar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"compass-preferences-model": "^2.33.4",
"hadron-app-registry": "^9.4.4",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-instance-model": "^12.26.4",
"mongodb-ns": "^2.4.2",
"mongodb-query-parser": "^4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"leaflet-defaulticon-compatibility": "^0.1.1",
"leaflet-draw": "^1.0.4",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-query-util": "^2.4.4",
"mongodb-schema": "^12.4.0",
"numeral": "^1.5.6",
Expand Down
6 changes: 3 additions & 3 deletions packages/compass-shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
"@mongodb-js/compass-user-data": "^0.5.4",
"@mongodb-js/compass-utils": "^0.8.4",
"@mongodb-js/compass-workspaces": "^0.31.4",
"@mongosh/browser-repl": "^3.5.0",
"@mongosh/logging": "^3.5.0",
"@mongosh/node-runtime-worker-thread": "^3.3.0",
"@mongosh/browser-repl": "^3.6.0",
"@mongosh/logging": "^3.6.0",
"@mongosh/node-runtime-worker-thread": "^3.3.1",
"bson": "^6.10.3",
"compass-preferences-model": "^2.33.4",
"hadron-app-registry": "^9.4.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-sidebar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"compass-preferences-model": "^2.33.4",
"hadron-app-registry": "^9.4.4",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-instance-model": "^12.26.4",
"mongodb-ns": "^2.4.2",
"react": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"is-ip": "^5.0.1",
"lodash": "^4.17.21",
"mocha": "^10.2.0",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-connection-string-url": "^3.0.1",
"mongodb-data-service": "^22.25.4",
"mongodb-ns": "^2.4.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/compass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@
"email": "[email protected]"
},
"dependencies": {
"@mongosh/node-runtime-worker-thread": "^3.3.0",
"@mongosh/node-runtime-worker-thread": "^3.3.1",
"clipboard": "^2.0.6",
"kerberos": "^2.2.0",
"kerberos": "^2.2.1",
"keytar": "^7.9.0",
"mongodb-client-encryption": "^6.1.0",
"mongodb-client-encryption": "^6.3.0",
"os-dns-native": "^1.2.1",
"system-ca": "^2.0.0"
},
Expand Down Expand Up @@ -262,7 +262,7 @@
"hadron-build": "^25.7.4",
"hadron-ipc": "^3.4.4",
"minimatch": "^10.0.1",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-build-info": "^1.7.2",
"mongodb-cloud-info": "^2.1.2",
"mongodb-connection-string-url": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/connection-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@mongodb-js/connection-info": "^0.11.4",
"@mongodb-js/shell-bson-parser": "^1.2.0",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-build-info": "^1.7.2",
"mongodb-connection-string-url": "^3.0.1",
"mongodb-data-service": "^22.25.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/connection-info/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"dependencies": {
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-connection-string-url": "^3.0.1",
"mongodb-data-service": "^22.25.4"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/data-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@mongodb-js/devtools-proxy-support": "^0.4.2",
"bson": "^6.10.3",
"lodash": "^4.17.21",
"mongodb": "^6.13.1",
"mongodb": "^6.14.1",
"mongodb-build-info": "^1.7.2",
"mongodb-connection-string-url": "^3.0.1",
"mongodb-ns": "^2.4.2"
Expand All @@ -76,7 +76,7 @@
"chai-as-promised": "^7.1.1",
"depcheck": "^1.4.1",
"eslint": "^7.25.0",
"kerberos": "^2.2.0",
"kerberos": "^2.2.1",
"mocha": "^10.2.0",
"mongodb-log-writer": "^2.3.4",
"nyc": "^15.1.0",
Expand All @@ -86,6 +86,6 @@
"typescript": "^5.0.4"
},
"optionalDependencies": {
"mongodb-client-encryption": "^6.1.0"
"mongodb-client-encryption": "^6.3.0"
}
}
2 changes: 1 addition & 1 deletion packages/data-service/src/csfle-collection-tracker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ describe('CSFLECollectionTracker', function () {
}
expect(err).to.be.instanceOf(Error);
expect(err.message).to.match(
/\[Compass\] Missing encrypted field information of collection/
/\[Compass\] Missing encrypted field information for collection/
);
});

Expand Down
104 changes: 65 additions & 39 deletions packages/data-service/src/csfle-collection-tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import parseNamespace from 'mongodb-ns';
import _ from 'lodash';
import type { UnboundDataServiceImplLogger } from './logger';
import { mongoLogId } from './logger';
import { EJSON } from 'bson';

/**
* A list of field paths for a document.
Expand Down Expand Up @@ -365,6 +366,12 @@ export class CSFLECollectionTrackerImpl implements CSFLECollectionTracker {
return info;
}

*_getCSFLECollectionNames(): Iterable<ReturnType<typeof parseNamespace>> {
for (const ns of this._nsToInfo.keys()) {
yield parseNamespace(ns);
}
}

updateCollectionInfo(
ns: string,
result: CollectionInfoNameOnly & Partial<CollectionInfo>
Expand Down Expand Up @@ -402,19 +409,21 @@ export class CSFLECollectionTrackerImpl implements CSFLECollectionTracker {
db: (dbName: string) => {
return {
listCollections: (filter: Document, opts: ListCollectionsOptions) => {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this; // there are no async generator arrow functions
return {
toArray: async () => {
[Symbol.asyncIterator]: async function* () {
const collectionInfos = await wrappedClient
.db(dbName)
.listCollections(filter, opts)
.toArray();
const err = this._checkListCollectionsForLibmongocryptResult(
const err = self._checkListCollectionsForLibmongocryptResult(
dbName,
filter,
(collectionInfos ?? []) as CollectionInfo[]
);
if (err) {
this._logger?.error(
self._logger?.error(
'COMPASS-DATA-SERVICE',
mongoLogId(1_001_000_122),
'CSFLECollectionTracker',
Expand All @@ -423,7 +432,7 @@ export class CSFLECollectionTrackerImpl implements CSFLECollectionTracker {
);
throw err;
}
return collectionInfos;
yield* collectionInfos;
},
};
},
Expand All @@ -437,53 +446,70 @@ export class CSFLECollectionTrackerImpl implements CSFLECollectionTracker {
filter: Document,
collectionInfos: CollectionInfo[]
): Error | undefined {
if (typeof filter?.name !== 'string' || collectionInfos.length > 1) {
// filter is either { name: string } or { name: { $in: string[] } }
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be documented as a type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, but the point here is that the input isn't of a known type ... we could split this out into a separate validation function if you prefer, that takes a generic unknown or Document input and returns this type

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I don't have strong feelings about it; leaving it as is is fine also 👍

if (
typeof filter?.name !== 'string' &&
(!filter?.name ||
typeof filter.name !== 'object' ||
!Array.isArray(filter.name.$in) ||
!(filter.name.$in as unknown[]).every(
(name) => typeof name === 'string'
))
) {
// This is an assertion more than an actual error condition.
// It ensures that we're only getting listCollections requests
// in the format that we expect them to come in.
return new Error(
`[Compass] Unexpected listCollections request on '${dbName}' with name: '${
filter?.name as string
}'`
`[Compass] Unexpected listCollections request on '${dbName}' with filter: ${EJSON.stringify(
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] Should we include the shape of the filter that we expect? I find it a much nicer DX when I get an error that not only tells me that I did something wrong, but also helps me do the right thing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could, but honestly I don't think that would be worth it, if this actually gets thrown at some point, that means we're going to have to do some digging into the root cause anyway

filter
)}`
);
}
const filterNames: string[] =
typeof filter.name === 'string' ? [filter.name] : filter.name.$in;

const ns = `${dbName}.${filter.name}`;
const existingInfo = this._getCSFLECollectionInfo(ns);

if (collectionInfos.length === 0) {
if (existingInfo.serverEnforcedEncryptedFields?.encryptedFields?.length) {
return new Error(
`[Compass] Missing encrypted field information of collection '${ns}'`
);
// First check: All collections for which we had existing encrypted fields
// in the server schema also have a collection schema in the new listCollections response
for (const existingNs of this._getCSFLECollectionNames()) {
if (
existingNs.database === dbName &&
filterNames.includes(existingNs.collection)
) {
const existingInfo = this._getCSFLECollectionInfo(existingNs.ns);
if (
existingInfo.serverEnforcedEncryptedFields?.encryptedFields?.length &&
!collectionInfos.some((info) => info.name === existingNs.collection)
) {
return new Error(
`[Compass] Missing encrypted field information for collection '${existingNs.ns}'`
);
}
}
return;
}

const [info] = collectionInfos;
if (filter.name !== info.name) {
// Also just a consistency check to make sure that things
// didn't go *terribly* wrong somewhere.
return new Error(
`[Compass] Unexpected listCollections name mismatch: got ${info.name}, expected ${filter.name}`
// Second check: All fields that were previously known to be encrypted
// are still encrypted in the new listCollections response
for (const info of collectionInfos) {
const ns = `${dbName}.${info.name}`;
const existingInfo = this._getCSFLECollectionInfo(ns);

const newInfo = extractEncryptedFieldsFromListCollectionsResult(
info.options
);
}
const newInfo = extractEncryptedFieldsFromListCollectionsResult(
info.options
);

for (const expectedEncryptedField of existingInfo
.serverEnforcedEncryptedFields?.encryptedFields ?? []) {
if (
!newInfo.encryptedFields.some((field) =>
_.isEqual(field, expectedEncryptedField)
)
) {
return new Error(
`[Compass] Missing encrypted field '${expectedEncryptedField.join(
'.'
)}' of collection '${ns}' in listCollections result`
);
for (const expectedEncryptedField of existingInfo
.serverEnforcedEncryptedFields?.encryptedFields ?? []) {
if (
!newInfo.encryptedFields.some((field) =>
_.isEqual(field, expectedEncryptedField)
)
) {
return new Error(
`[Compass] Missing encrypted field '${expectedEncryptedField.join(
'.'
)}' of collection '${ns}' in listCollections result`
);
}
}
}
}
Expand Down
Loading