Skip to content

feat(auto-updater): Error when requesting updates from an outdated MacOS machine COMPASS-9081 #6851

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
Apr 14, 2025

Conversation

kraenhansen
Copy link
Contributor

@kraenhansen kraenhansen commented Apr 9, 2025

Description

Merging this PR will:

  • Propagate MacOS product version to the update server (through a query-string param).
  • React to the server sending a response of status 426 (Upgrade Required) and parse the body of the response to determine any reason for the rejection.
  • If the reason is determined to be 'outdated-operating-system' the updater will transition to a new OutdatedOperatingSystem state.
  • This will propagate to the UI with a custom alert message (when the update was manually checked) and a toast to inform the user of the outdated operating system. Both with a link to the system requirements: https://www.mongodb.com/docs/compass/current/install/

After manual check

Screenshot 2025-04-11 at 11 40 29

After automatic or manual check

Screenshot 2025-04-11 at 11 40 35

You can verify the behaviour introduced with this PR by running Compass locally on a Mac passing a fake version (to bypass the skip in the update server) and update server endpoint:

HADRON_APP_VERSION=0.0.1-dev.1 HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE=http://localhost:8080 npm start

Use this with the update server from https://github.com/10gen/compass-mongodb-com/pull/129 updating the MINIMUM_MACOS_VERSION to a future version of MacOS ("20.0.0" or something).

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

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 self-assigned this Apr 9, 2025
@kraenhansen kraenhansen changed the title feat(auto-updater): Error when requesting updates from an outdated MacOS machine feat(auto-updater): Error when requesting updates from an outdated MacOS machine COMPASS-9081 Apr 9, 2025
@kraenhansen kraenhansen force-pushed the kh/send-darwin-info-when-updating branch 2 times, most recently from 7ba33c2 to 1b962c9 Compare April 10, 2025 10:01
@github-actions github-actions bot added the feat label Apr 10, 2025
@kraenhansen kraenhansen requested a review from Copilot April 10, 2025 10:58
Copy link

@Copilot 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.

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • packages/compass/package.json: Language not supported

@kraenhansen kraenhansen force-pushed the kh/send-darwin-info-when-updating branch from 1b962c9 to d88461c Compare April 10, 2025 11:02
@mongodb-js mongodb-js deleted a comment from Copilot bot Apr 10, 2025
@kraenhansen kraenhansen added the no release notes Fix or feature not for release notes label Apr 10, 2025
@kraenhansen kraenhansen marked this pull request as ready for review April 10, 2025 16:08
@kraenhansen kraenhansen force-pushed the kh/send-darwin-info-when-updating branch from d88461c to 7cdc3eb Compare April 10, 2025 16:10
description: 'Downloading a newer Compass version failed',
description:
reason === 'outdated-operating-system'
? 'The version of your operating system is no longer supported.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe a link to the docs install page where we list minimal reqs? This one https://www.mongodb.com/docs/compass/current/install/

Copy link
Contributor Author

@kraenhansen kraenhansen Apr 11, 2025

Choose a reason for hiding this comment

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

👍 I wonder if that would be clickable? 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have both buttons and links in toasts in some places in Compass, if you render it as a link, it should be clickable

message: 'There are currently no updates available.',
message:
updateInfo.reason === 'outdated-operating-system'
? `The version of your operating system is no longer supported. Expected at least v${updateInfo.expectedVersion}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would maybe run this through product. Personally I'm not sure how common it is to prefix an OS version with v and it caught my eye 🙂 Maybe we can do a better wording here and also link to the docs (same link I mentioned above)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A link here wouldn't be clickable, in which case a button on the message box would be better? 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, right, it's a native box, skipped my mind. Hmmm, yeah, not sure, can try a button for this, but might be slightly weird too 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

(Don't want to overcomplicate this too, so your call if it's too much extra effort)

Copy link
Contributor Author

@kraenhansen kraenhansen Apr 11, 2025

Choose a reason for hiding this comment

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

I added a button - it seems better to me 👍

Comment on lines 677 to 695
assert(
typeof json === 'object' && json !== null,
'Expected response to be an object'
);
if ('reason' in json && json.reason === 'outdated-operating-system') {
assert(
'expectedVersion' in json,
"Expected 'expectedVersion' in response"
);
const { expectedVersion } = json;
assert(
typeof expectedVersion === 'string',
"Expected 'expectedVersion' in response"
);
return {
available: false,
reason: 'outdated-operating-system',
expectedVersion,
};
Copy link
Collaborator

@gribnoysup gribnoysup Apr 11, 2025

Choose a reason for hiding this comment

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

Nit: you have a custom catch for the response assertion below, but not here. If we think it's worth having custom logging for the one below, it's probably worth here too?

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 added a try-catch around this parsing with a message that add a bit more context 👍

Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

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

Didn't have a chance to run this code myself, but reading through it looks good (only small nit about error handling)! I would probalby double-check that copy looks okay to product

@kraenhansen
Copy link
Contributor Author

I've added links to the system requirements and updated the screenshots accordingly 👍

@kraenhansen kraenhansen merged commit c060544 into main Apr 14, 2025
82 of 83 checks passed
@kraenhansen kraenhansen deleted the kh/send-darwin-info-when-updating branch April 14, 2025 08:33
@kraenhansen
Copy link
Contributor Author

kraenhansen commented Apr 14, 2025

Merging as @betsybutton gave a LGTM on Slack 👍

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.

2 participants