Skip to content

Conversation

@kraenhansen
Copy link
Contributor

This PR depends on mongodb-js/devtools-shared#587 being merged and released: I wanted to get this up as a draft to get some early feedback.

@kraenhansen kraenhansen self-assigned this Oct 31, 2025
Comment on lines 133 to 134
dl_version: null,
atlas_version: null,
Copy link
Contributor Author

@kraenhansen kraenhansen Oct 31, 2025

Choose a reason for hiding this comment

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

This shows that the types were actually wrong. mongodb-build-info has always been sending null for missing values, I just updated the types to match this in mongodb-build-info.

The signature of ConnectionExtraInfo prevents this (these properties are ? optional). I could either update the type here to accept null or map null to undefined (what I propose - to avoid propagating the breakage in types).

@kraenhansen kraenhansen requested a review from addaleax October 31, 2025 15:33
@kraenhansen kraenhansen force-pushed the kh/bump-mongodb-build-info branch from ab42194 to 83ff11d Compare October 31, 2025 18:26
// ^ segment data is in snake_case: forgive me javascript, for i have sinned.

import getBuildInfo from 'mongodb-build-info';
import * as getBuildInfo from 'mongodb-build-info';
Copy link
Collaborator

Choose a reason for hiding this comment

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

All the 💙 for moving towards correct imports!

Comment on lines 505 to 507
buildInfo: buildInfoPromise.then((bi) => bi ?? {}),
adminCommand: (command) =>
this.runCommandWithCheck('admin', command, this.baseCmdOptions),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here's what I'd have in mind for mongodb-js/devtools-shared#587 (review):

Suggested change
buildInfo: buildInfoPromise.then((bi) => bi ?? {}),
adminCommand: (command) =>
this.runCommandWithCheck('admin', command, this.baseCmdOptions),
adminCommand: async (command) => {
if (command.buildInfo)
return (await buildInfoPromise) ?? {};
return await this.runCommandWithCheck('admin', command, this.baseCmdOptions);
},

This is optional but I do feel like this is the right way to go, identifyServerName() shouldn't have to care. about whether the call to adminCommand actually runs a command or returns cached data

Copy link
Contributor Author

@kraenhansen kraenhansen Nov 1, 2025

Choose a reason for hiding this comment

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

You're right, this is a great idea 👍
It's more flexible and scalable as we might want to call more commands in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a fix doing this 👍

@kraenhansen kraenhansen force-pushed the kh/bump-mongodb-build-info branch from 83ff11d to 0658657 Compare November 3, 2025 11:10
@kraenhansen kraenhansen requested a review from addaleax November 3, 2025 11:10
@kraenhansen kraenhansen marked this pull request as ready for review November 3, 2025 11:10
@kraenhansen kraenhansen requested a review from a team as a code owner November 3, 2025 11:10
Copilot AI review requested due to automatic review settings November 3, 2025 11:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR bumps the mongodb-build-info dependency to version ^1.8.1 and integrates the new identifyServerName function to improve server identification. The change replaces the previous approach of using getGenuineMongoDB with a more comprehensive server name identification that leverages the identifyServerName API.

Key changes:

  • Integration of identifyServerName from mongodb-build-info to identify server types more accurately
  • Refactored connection info gathering to use the new API
  • Updated import style from default to namespace import for mongodb-build-info

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/service-provider-node-driver/src/node-driver-service-provider.ts Added identifyServerName call in getConnectionInfo() and restructured promise handling
packages/service-provider-node-driver/src/node-driver-service-provider.spec.ts Updated test expectations to account for additional command call
packages/service-provider-node-driver/package.json Bumped mongodb-build-info dependency to ^1.8.1
packages/service-provider-core/src/connect-info.ts Changed import style and refactored to use serverName parameter instead of calling getGenuineMongoDB
packages/service-provider-core/src/connect-info.spec.ts Updated test expectations and added serverName parameter to test calls
packages/service-provider-core/package.json Bumped mongodb-build-info dependency to ^1.8.1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +482 to +488
const [
buildInfo,
atlasVersion = null,
fcv = null,
atlascliInfo,
serverName,
] = await Promise.all([
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The buildInfo destructured from the Promise.all result has no default value, but buildInfoPromise can resolve to an empty object {} when the catch handler executes. This inconsistency means buildInfo could be {} instead of the expected buildInfo response structure. Consider adding a default value of {} to match the catch handler's return value.

Copilot uses AI. Check for mistakes.
atlas_version: atlasVersion?.atlasVersion ?? null,
is_genuine,
non_genuine_server_name,
is_genuine: serverName === 'mongodb' || serverName === 'unknown',
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

[nitpick] The logic for determining is_genuine treats 'unknown' as genuine, which may be misleading. If server identification fails and returns 'unknown', it's unclear whether the server is genuine or not. Consider documenting this behavior or adjusting the logic to handle the 'unknown' case more explicitly.

Suggested change
is_genuine: serverName === 'mongodb' || serverName === 'unknown',
is_genuine: serverName === 'unknown' ? undefined : serverName === 'mongodb',

Copilot uses AI. Check for mistakes.
@kraenhansen kraenhansen changed the title chore(deps) bump mongodb-build-info chore(deps): bump mongodb-build-info Nov 3, 2025
@kraenhansen
Copy link
Contributor Author

kraenhansen commented Nov 3, 2025

The failure on this seem unrelated to the changes I'm introducing and it looks like they're matching those raised in #2562

Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

:shipit:

@kraenhansen kraenhansen merged commit 599af61 into main Nov 3, 2025
146 of 156 checks passed
@kraenhansen kraenhansen deleted the kh/bump-mongodb-build-info branch November 3, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants