Repository navigation
fix(frontend): use version id for version links when version_number is ambiguous - #8093
Open
TheRealAlexxx wants to merge 1 commit into
Open
TheRealAlexxx wants to merge 1 commit into
TheRealAlexxx wants to merge 1 commit into
Conversation
Versions that share a version_number within a project (common for multi-loader releases) produce an ambiguous /version/<number> route: the API resolves the number to an arbitrary match, so clicking the NeoForge entry on modrinth.com/mod/moonlight/versions opens the Fabric build. The previous first-published-wins tiebreak cannot pick the owner reliably - bulk-published versions land within the same millisecond, where date ordering degenerates to input order. Assign every duplicated version_number its unique version id as the display URL ending instead; unambiguous numbers keep their slug. Fixes modrinth#8018
Contributor
Pull request changelogAppAddedChangedDeprecatedRemovedFixedSecurityWebsiteAddedChangedDeprecatedRemovedFixedSecurityHostingAddedChangedDeprecatedRemovedFixedSecurity |
|
Tick the box to add this pull request to the merge queue (same as
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix duplicate version slugs breaking version page routing
Fixes #8018
Problem
When two versions of a project share the same
version_number(possible acrossdifferent loaders, e.g.
1.21.1-3.7.2published for both Fabric and NeoForge),the version page at
/mod/<project>/version/<version_number>shows only one ofthem, and the other has no working slug URL. Both versions remain reachable via
their version ID.
Reproduced live (signed out, 2026-10-23) on
mod/moonlight:1.21.1-3.7.2(FabricfWlk6YEB, NeoForgefAIfWX6M),published within the same millisecond.
/mod/moonlight/version/1.21.1-3.7.2loads the Fabric build's page; theNeoForge build has no working slug URL.
Root cause
In
apps/frontend/src/plugins/shorthands.js,computeVersionsdecides whichversion keeps the human-readable
version_numberslug when duplicates exist.The tie-break sorts by
date_published, but when versions are bulk-publishedwithin the same millisecond the comparator ties (both timestamps truncate to
the same value), so which duplicate keeps the slug depends on the order
versions arrive in the API response. The duplicated number then routes to only
one of the two versions. Every version link on the site (versions list,
changelog, settings) funnels through this one computation.
Fix
In
computeVersions, count occurrences of eachversion_number. Any versionwhose number appears more than once is exposed under its unique version
idinstead of the ambiguous slug, so every version always has a stable, unique
route. Versions with unique numbers keep their human-friendly slugs, so there
is no change for the common case.
Verification
I didn't find frontend unit-test infrastructure in this repo (the prepr pipeline
runs lint/format/i18n tasks, no test runner), so behavioral verification used a
standalone Node harness replaying the old and new
computeVersionslogicagainst fixtures matching the live
moonlightdata (duplicate numbers,same-millisecond publish):
depends on input ordering (bug reproduced).
result is independent of input ordering.
node --check, and the repo's fullpnpm prepr:frontend:webpipeline (turbo: eslint, prettier, intl extract,and related tasks across the frontend workspace) passes: 14/14 tasks
successful, 0 errors, and its auto-fix steps make no changes to the patched
file.