Skip to content

Conversation

@kraenhansen
Copy link
Contributor

Description

As a preparation for a PR adding specific reasons for auto updates being unavailable I'm refactoring the auto updater to return an object with { available: false } instead of null when an update is not available.

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
Comment on lines +642 to +656
const json = await response.json();
assert(
typeof json === 'object' && json !== null,
'Expected response to be an object'
);
assert('name' in json, 'Expected "name" in response');
assert('to' in json, 'Expected "to" in response');
assert('from' in json, 'Expected "from" in response');

const { name, from, to } = json;
assert(typeof name === 'string', 'Expected "name" to be a string');
assert(typeof from === 'string', 'Expected "from" to be a string');
assert(typeof to === 'string', 'Expected "to" to be a string');

return { available: true, name, from, to };
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'm including this more defensive parsing of the response from the server.

@kraenhansen kraenhansen added no release notes Fix or feature not for release notes no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) labels Apr 9, 2025
}


assert(response.ok);
Copy link
Collaborator

@gribnoysup gribnoysup Apr 9, 2025

Choose a reason for hiding this comment

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

Are we changing the backend to return more success status codes than 200 (EDIT: meaning with actual update data and not empty)? I don't think we expect anything else but 200 as a success state, not sure why we're making the check less strict here

Copy link
Contributor Author

@kraenhansen kraenhansen Apr 9, 2025

Choose a reason for hiding this comment

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

I'll revert the change and return early instead 👍 (it was a leftover change from the codeI'm introducing in #6850 - where I needed the check to be less strict, but I later moved this assert below my new code).

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.

Not sure why we're allowing more responses now, but maybe that's expected. Otherwise looks good

@gribnoysup gribnoysup changed the title Refactor auto-updater to return objects when no update is available chore(compass-main): refactor auto-updater to return objects when no update is available Apr 9, 2025
@kraenhansen kraenhansen merged commit 4085b6c into main Apr 10, 2025
55 checks passed
@kraenhansen kraenhansen deleted the kh/refactor-auto-updater branch April 10, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no release notes Fix or feature not for release notes no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants