Skip to content

feat(connections): warn then connecting to an end-of-life server COMPASS-9083 #6888

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

Merged
merged 12 commits into from
May 12, 2025

Conversation

kraenhansen
Copy link
Contributor

@kraenhansen kraenhansen commented May 2, 2025

Description

Merging this PR will:

  • Add a warning modal similar to the "Non Genuine Connection Modal" shown when connecting to MongoDB 4.4.
  • Remove the "cancel" button from the "Non Genuine Connection Modal", to align with the now modal and because it serves no purpose and is actually slightly misleading as connecting cannot be cancelled by pressing the button.
  • Updates test fixtures to use server version 100.0.0, to avoid working around the new modal in existing tests.

Screenshot 2025-05-02 at 10 13 34

Screen.Recording.2025-05-02.at.10.11.41.mov

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

  • Will the build info be present and potentially misleading when connecting to a non-genuine server? And do we care about that?

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@kraenhansen kraenhansen added the no release notes Fix or feature not for release notes label May 2, 2025
@kraenhansen kraenhansen self-assigned this May 2, 2025
@github-actions github-actions bot added the feat label May 2, 2025
@kraenhansen
Copy link
Contributor Author

kraenhansen commented May 2, 2025

😬 I just realized (and remembered) that @alenakhineika had already made a draft PR adding this #6805 🙈 I'll pick some of her ideas into this branch (as this has tests) and add a call to the update server.

export function isEndOfLifeVersion(version: string) {
try {
const [major, minor] = version.split('.').map((part) => parseInt(part, 10));
return (major === 4 && minor <= 4) || major < 4;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're already taking this from the buildInfo output, is there any reason not to use versionArray directly?

Copy link
Contributor Author

@kraenhansen kraenhansen May 2, 2025

Choose a reason for hiding this comment

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

Mostly that I wasn't aware that this was included in the build info.

Never the less, I expect these lines to go away and instead I'll be using "semver" like Alena did in her PR:

export function isEndOfLifeServer(
serverVersion: string | undefined | null
): boolean {
if (!serverVersion) {
return true;
}
try {
return semver.satisfies(serverVersion, `<=${getEoLServerVersion()}`);
} catch (e) {
return true;
}
}

Comment on lines 5 to 6
const { HADRON_AUTO_UPDATE_ENDPOINT, HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE } =
process.env;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if there's a better place to put these. Some package intended to share constants across the main and renderer processes.

@kraenhansen kraenhansen force-pushed the kh/warn-on-eol-server-connection branch 2 times, most recently from 34b369e to c5ab3b2 Compare May 7, 2025 09:21
@kraenhansen kraenhansen marked this pull request as ready for review May 7, 2025 12:18
@kraenhansen kraenhansen force-pushed the kh/warn-on-eol-server-connection branch from c5ab3b2 to b88316c Compare May 7, 2025 12:55
@@ -23,6 +23,7 @@ export function showNonGenuineMongoDBWarningModal(
) {
return showConfirmation({
title: 'Non-Genuine MongoDB Detected',
hideCancelButton: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suggest hiding the cancel button on this as well, to keep things aligned and because canceling this modal won't stop connecting anyway.

@kraenhansen kraenhansen requested a review from lerouxb May 9, 2025 11:46
return (_dispatch, getState, { track }) => {
const connectionInfo = getCurrentConnectionInfo(getState(), connectionId);
track('Screen', { name: 'end_of_life_mongodb_modal' }, connectionInfo);
void _showEndOfLifeMongoDBWarningModal(connectionInfo, version);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nit, but I'd personally probably have jumped through hoops to come up with two different names where one showEndOfLifeMongoDBWarningModal is the thunk action creator thingy and one is the function from the component. But I can live with this ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH, I didn't pay too much attention to naming there as I was mostly copying from the code above:

export const showNonGenuineMongoDBWarningModal = (
connectionId: string
): ConnectionsThunkAction<void> => {
return (_dispatch, getState, { track }) => {
const connectionInfo = getCurrentConnectionInfo(getState(), connectionId);
track('Screen', { name: 'non_genuine_mongodb_modal' }, connectionInfo);
void _showNonGenuineMongoDBWarningModal(connectionInfo);
};
};

latestEndOfLifeServerVersion: string
) {
try {
const coercedVersion = semverCoerce(version);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to understand under which circumstances this would be falsy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the docs:

Only text which lacks digits will fail coercion (version one is not valid).

Copy link
Contributor

Choose a reason for hiding this comment

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

But.. will it throw or be falsy? You seem to be checking/accounting for both and it isn't clear to me that both can happen.

Copy link
Contributor Author

@kraenhansen kraenhansen May 12, 2025

Choose a reason for hiding this comment

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

The try-catch is mostly to be extra safe that these calls won't prevent the caller from progressing - if we're unsure, we'll opt on the safe side instead of propagating errors. This also handles if semverSatisfies or any future code added to the block throws for some reason.

The check for falsy coercedVersion is the known case of a malformed server version. This is mostly to handle that we might fail to determine a non-genuine server with a malformed version or a future MongoDB version which is not able to coerce, for some unknown reason.

@kraenhansen kraenhansen requested a review from addaleax May 9, 2025 22:40
@kraenhansen kraenhansen merged commit 0db3c9e into main May 12, 2025
56 checks passed
@kraenhansen kraenhansen deleted the kh/warn-on-eol-server-connection branch May 12, 2025 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants