fix(installations): sort VS Versions without throwing on an unparseable one - #284
fix(installations): sort VS Versions without throwing on an unparseable one#284Pixnop wants to merge 1 commit into
Conversation
…le one Opening an Installation for editing showed nothing but a grey window. The version picker sorts the registered VS Versions with semver.rcompare, which throws on a string semver cannot parse, and a throw inside a sort callback during render takes the whole page down. The Add Installation form picks its default version the same way and went down on the same data. A registered version is whatever the game printed for `-v`, stored as-is by the version probe, so a modded build or a launcher that answered with more than a bare number leaves something like "Vintage Story 1.21.0" in the config and both forms stop opening. The versions list already guarded this after #148. That guard is now one comparator in the renderer's utils, and all three sort sites use it. Valid versions order among themselves as before, unparseable ones sort last, alphabetically.
Zaldaryon
left a comment
There was a problem hiding this comment.
Approved. This fixes the blank Installation screens when a registered game version contains output that semver cannot parse. The shared comparator preserves newest-first semver ordering, moves unparseable strings after valid versions, and keeps alphabetical ordering among invalid values. It is used by ListVersions, GameVersionPicker, and the Add Installation default selection. The added tests cover the comparator branches and both affected forms.\n\nLocal verification passed: npm run typecheck; npm run lint:ci with 0 errors and 15 existing warnings; npm run format:check; targeted comparator and installation-form tests with 20 passed; npm run test:coverage with 138 files, 1640 passed, 2 skipped, and coverage of 92.61% statements, 89.87% branches, 92.04% functions, and 94.06% lines; and npm run build:unpack. GitHub typecheck, lint, test, SonarCloud, Ubuntu build, and Windows build checks passed. The macOS build is policy-skipped.
Zaldaryon
left a comment
There was a problem hiding this comment.
Approved. This fixes the blank Installation screens when a registered game version contains output that semver cannot parse. The shared comparator preserves newest-first semver ordering, moves unparseable strings after valid versions, and keeps alphabetical ordering among invalid values. It is used by ListVersions, GameVersionPicker, and the Add Installation default selection. The added tests cover the comparator branches and both affected forms.
Local verification passed: npm run typecheck; npm run lint:ci with 0 errors and 15 existing warnings; npm run format:check; targeted comparator and installation-form tests with 20 passed; npm run test:coverage with 138 files, 1640 passed, 2 skipped, and coverage of 92.61% statements, 89.87% branches, 92.04% functions, and 94.06% lines; and npm run build:unpack. GitHub typecheck, lint, test, SonarCloud, Ubuntu build, and Windows build checks passed. The macOS build is policy-skipped.
Zaldaryon
left a comment
There was a problem hiding this comment.
RiftLauncher PR #284 review
Decision
Approved.
Review
This fixes the blank Installation screens when a registered game version contains output that semver cannot parse. The shared comparator preserves newest-first semver ordering, moves unparseable strings after valid versions, and keeps alphabetical ordering among invalid values. It is used by ListVersions, GameVersionPicker, and the Add Installation default selection. The added tests cover the comparator branches and both affected forms.
Verification
npm run typecheckpassed.npm run lint:cipassed with 0 errors and 15 existing warnings.npm run format:checkpassed.- Targeted comparator and installation-form tests passed: 20 tests.
npm run test:coveragepassed: 138 files, 1640 tests passed, 2 skipped. Coverage was 92.61% statements, 89.87% branches, 92.04% functions, and 94.06% lines.npm run build:unpackpassed on Linux.- GitHub typecheck, lint, test, SonarCloud, Ubuntu build, and Windows build checks passed. The macOS build is skipped by workflow policy.
Duplicate approval superseded by the final Markdown review.
A player on ModDB reported that in 1.7.0-beta.4, clicking the pencil to edit an Installation drops them on a blank grey window. Nothing renders, no message, and the only way out is the keyboard shortcut back or restarting the launcher.
The version picker sorts the registered VS Versions with
semver.rcompare. That function throws on a string it cannot parse, and here it is called straight from a sort callback while the component renders, so the throw escapes the render pass and React unmounts the tree. There is no error boundary above the routes, so what is left on screen is the empty background.A registered version is whatever the game answered when the launcher probed it with
-v. The probe trims that stdout and stores it as it came, so a modded build, a pre-release, or anything that printed more than a bare number puts a string like "Vintage Story 1.21.0" in the config. From that moment the edit form will not open. The Add Installation form picks its default version by sorting the same list, so it went blank on the same data, and any player who reached this state could neither edit an Installation nor create one.The versions list page hit exactly this in #148 and got a guarded comparator inline back then. That guard is now a single function in the renderer's utils, and the three places that sort versions all call it: the picker shared by both Installation forms, the Add form's default selection, and the versions list. Valid versions order among themselves the way they always did, anything unparseable sorts after them alphabetically so the order does not shift between renders.
Reproduced against the shipped 1.7.0-beta.4 build and against a build of dev, both with a config holding one ordinary version and one unparseable one: the edit page renders nothing and the console carries
TypeError: Invalid Version: Vintage Story 1.21.0fromGameVersionPicker. With this branch the same config opens the form with both versions listed and no exception.Tests cover the comparator directly, and both Installation forms now have a case that mounts them on the reproducing config. All three fail without the guard.