Skip to content

Commit 599af61

Browse files
authored
chore(deps): bump mongodb-build-info (#2563)
* Bump mongodb-build-info to 1.8.1 * Map null to undefined to match types * Add call to identifyServerName in service-provider-node-driver
1 parent ee71237 commit 599af61

File tree

7 files changed

+97
-45
lines changed

7 files changed

+97
-45
lines changed

package-lock.json

Lines changed: 29 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/service-provider-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@mongosh/shell-bson": "1.0.2",
4141
"bson": "^6.10.4",
4242
"mongodb": "^6.19.0",
43-
"mongodb-build-info": "^1.7.2",
43+
"mongodb-build-info": "^1.8.1",
4444
"mongodb-connection-string-url": "^3.0.2"
4545
},
4646
"devDependencies": {

packages/service-provider-core/src/connect-info.spec.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('getConnectInfo', function () {
6464
auth_type: 'PLAIN',
6565
is_data_federation: false,
6666
is_stream: false,
67-
dl_version: null,
67+
dl_version: undefined,
6868
atlas_version: '20210330.0.0.1617063608',
6969
is_genuine: true,
7070
non_genuine_server_name: 'mongodb',
@@ -81,6 +81,7 @@ describe('getConnectInfo', function () {
8181
atlasVersion: ATLAS_VERSION,
8282
resolvedHostname: 'test-data-sets-00-02-a011bb.mongodb.net',
8383
isLocalAtlas: false,
84+
serverName: 'mongodb',
8485
})
8586
).to.deep.equal(output);
8687
});
@@ -96,7 +97,7 @@ describe('getConnectInfo', function () {
9697
auth_type: undefined,
9798
is_data_federation: false,
9899
is_stream: false,
99-
dl_version: null,
100+
dl_version: undefined,
100101
atlas_version: '20210330.0.0.1617063608',
101102
is_genuine: true,
102103
non_genuine_server_name: 'mongodb',
@@ -113,6 +114,7 @@ describe('getConnectInfo', function () {
113114
atlasVersion: ATLAS_VERSION,
114115
resolvedHostname: 'test-data-sets-00-02-a011bb.mongodb.net',
115116
isLocalAtlas: false,
117+
serverName: 'mongodb',
116118
})
117119
).to.deep.equal(output);
118120
});
@@ -130,7 +132,7 @@ describe('getConnectInfo', function () {
130132
auth_type: undefined,
131133
is_data_federation: false,
132134
is_stream: true,
133-
dl_version: null,
135+
dl_version: undefined,
134136
atlas_version: null,
135137
is_genuine: true,
136138
is_local_atlas: false,
@@ -148,6 +150,7 @@ describe('getConnectInfo', function () {
148150
resolvedHostname:
149151
'atlas-stream-67b8e1cd6d60357be377be7b-1dekw.virginia-usa.a.query.mongodb-dev.net',
150152
isLocalAtlas: false,
153+
serverName: 'mongodb',
151154
})
152155
).to.deep.equal(output);
153156
});
@@ -163,7 +166,7 @@ describe('getConnectInfo', function () {
163166
auth_type: undefined,
164167
is_data_federation: false,
165168
is_stream: false,
166-
dl_version: null,
169+
dl_version: undefined,
167170
atlas_version: null,
168171
is_genuine: true,
169172
non_genuine_server_name: 'mongodb',
@@ -179,6 +182,7 @@ describe('getConnectInfo', function () {
179182
atlasVersion: null,
180183
resolvedHostname: 'localhost',
181184
isLocalAtlas: true,
185+
serverName: 'mongodb',
182186
})
183187
).to.deep.equal(output);
184188
});
@@ -194,13 +198,13 @@ describe('getConnectInfo', function () {
194198
auth_type: undefined,
195199
is_data_federation: false,
196200
is_stream: false,
197-
dl_version: null,
201+
dl_version: undefined,
198202
atlas_version: null,
199203
is_genuine: true,
200204
non_genuine_server_name: 'mongodb',
201-
server_arch: null,
202205
node_version: process.version,
203-
server_os: null,
206+
server_os: undefined,
207+
server_arch: undefined,
204208
uri: '',
205209
is_local_atlas: false,
206210
};
@@ -209,6 +213,7 @@ describe('getConnectInfo', function () {
209213
buildInfo: null,
210214
atlasVersion: null,
211215
isLocalAtlas: false,
216+
serverName: 'mongodb',
212217
})
213218
).to.deep.equal(output);
214219
});

packages/service-provider-core/src/connect-info.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ^ segment data is in snake_case: forgive me javascript, for i have sinned.
22

3-
import getBuildInfo from 'mongodb-build-info';
3+
import * as getBuildInfo from 'mongodb-build-info';
44
import type { ConnectionString } from 'mongodb-connection-string-url';
55

66
export type ConnectionExtraInfo = {
@@ -65,44 +65,43 @@ export default function getConnectExtraInfo({
6565
atlasVersion,
6666
resolvedHostname,
6767
isLocalAtlas,
68+
serverName = 'unknown',
6869
}: {
6970
connectionString?: ConnectionString;
7071
buildInfo: any;
7172
atlasVersion: any;
7273
resolvedHostname?: string;
7374
isLocalAtlas: boolean;
75+
serverName?: string;
7476
}): ConnectionExtraInfo {
7577
const auth_type =
7678
connectionString?.searchParams.get('authMechanism') ?? undefined;
7779
const uri = connectionString?.toString() ?? '';
7880

7981
buildInfo ??= {}; // We're currently not getting buildInfo with --apiStrict.
80-
const { isGenuine: is_genuine, serverName: non_genuine_server_name } =
81-
getBuildInfo.getGenuineMongoDB(uri);
8282
// Atlas Data Lake has been renamed to Atlas Data Federation
83-
const { isDataLake: is_data_federation, dlVersion: dl_version } =
83+
const { isDataLake: is_data_federation, dlVersion } =
8484
getBuildInfo.getDataLake(buildInfo);
8585

86-
const { serverOs: server_os, serverArch: server_arch } =
87-
getBuildInfo.getBuildEnv(buildInfo);
86+
const { serverOs, serverArch } = getBuildInfo.getBuildEnv(buildInfo);
8887
const isAtlas = !!atlasVersion?.atlasVersion || getBuildInfo.isAtlas(uri);
8988

9089
return {
9190
...getHostInformation(resolvedHostname || uri),
9291
is_atlas: isAtlas,
9392
server_version: buildInfo.version,
9493
node_version: process.version,
95-
server_os,
94+
server_os: serverOs || undefined,
9695
uri,
97-
server_arch,
96+
server_arch: serverArch || undefined,
9897
is_enterprise: getBuildInfo.isEnterprise(buildInfo),
9998
auth_type,
10099
is_data_federation,
101100
is_stream: getBuildInfo.isAtlasStream(uri),
102-
dl_version,
101+
dl_version: dlVersion || undefined,
103102
atlas_version: atlasVersion?.atlasVersion ?? null,
104-
is_genuine,
105-
non_genuine_server_name,
103+
is_genuine: serverName === 'mongodb' || serverName === 'unknown',
104+
non_genuine_server_name: serverName,
106105
is_local_atlas: isLocalAtlas,
107106
};
108107
}

packages/service-provider-node-driver/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@mongosh/types": "^3.14.0",
5555
"aws4": "^1.12.0",
5656
"mongodb": "^6.19.0",
57+
"mongodb-build-info": "^1.8.1",
5758
"mongodb-connection-string-url": "^3.0.2",
5859
"socks": "^2.8.3",
5960
"mongodb-client-encryption": "^6.5.0",

packages/service-provider-node-driver/src/node-driver-service-provider.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ describe('NodeDriverServiceProvider', function () {
10071007
expect(info.extraInfo?.is_local_atlas).to.equal(false);
10081008
expect(info.extraInfo?.is_localhost).to.equal(true);
10091009
expect(info.extraInfo?.fcv).to.equal(undefined);
1010-
expect(dbStub.command).to.have.callCount(3);
1010+
expect(dbStub.command).to.have.callCount(4);
10111011
expect(
10121012
dbStub.collection,
10131013
'calls countDocument on collection to check local atlas cli support'

packages/service-provider-node-driver/src/node-driver-service-provider.ts

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import {
9393
ClientEncryption,
9494
} from 'mongodb';
9595
import { connectMongoClient } from '@mongodb-js/devtools-connect';
96+
import { identifyServerName } from 'mongodb-build-info';
9697

9798
const bsonlib = () => {
9899
const {
@@ -472,27 +473,47 @@ export class NodeDriverServiceProvider
472473
}
473474

474475
async getConnectionInfo(): Promise<ConnectionInfo> {
475-
const [buildInfo = null, atlasVersion = null, fcv = null, atlascliInfo] =
476-
await Promise.all([
477-
this.runCommandWithCheck(
478-
'admin',
479-
{ buildInfo: 1 },
480-
this.baseCmdOptions
481-
).catch(() => {}),
482-
this.runCommandWithCheck(
483-
'admin',
484-
{ atlasVersion: 1 },
485-
this.baseCmdOptions
486-
).catch(() => {}),
487-
this.runCommandWithCheck(
488-
'admin',
489-
{ getParameter: 1, featureCompatibilityVersion: 1 },
490-
this.baseCmdOptions
491-
).catch(() => {}),
492-
this.countDocuments('admin', 'atlascli', {
493-
managedClusterType: 'atlasCliLocalDevCluster',
494-
}).catch(() => 0),
495-
]);
476+
const buildInfoPromise = this.runCommandWithCheck(
477+
'admin',
478+
{ buildInfo: 1 },
479+
this.baseCmdOptions
480+
).catch(() => ({}));
481+
482+
const [
483+
buildInfo,
484+
atlasVersion = null,
485+
fcv = null,
486+
atlascliInfo,
487+
serverName,
488+
] = await Promise.all([
489+
buildInfoPromise,
490+
this.runCommandWithCheck(
491+
'admin',
492+
{ atlasVersion: 1 },
493+
this.baseCmdOptions
494+
).catch(() => {}),
495+
this.runCommandWithCheck(
496+
'admin',
497+
{ getParameter: 1, featureCompatibilityVersion: 1 },
498+
this.baseCmdOptions
499+
).catch(() => {}),
500+
this.countDocuments('admin', 'atlascli', {
501+
managedClusterType: 'atlasCliLocalDevCluster',
502+
}).catch(() => 0),
503+
identifyServerName({
504+
connectionString: this.uri?.toString() ?? '',
505+
adminCommand: (command) => {
506+
if (command.buildInfo) {
507+
return buildInfoPromise;
508+
}
509+
return this.runCommandWithCheck(
510+
'admin',
511+
command,
512+
this.baseCmdOptions
513+
);
514+
},
515+
}),
516+
]);
496517

497518
const resolvedHostname = this._getHostnameForConnection(
498519
this._lastSeenTopology
@@ -504,6 +525,7 @@ export class NodeDriverServiceProvider
504525
atlasVersion,
505526
resolvedHostname,
506527
isLocalAtlas: !!atlascliInfo,
528+
serverName,
507529
});
508530

509531
return {

0 commit comments

Comments
 (0)