Skip to content

fix(frontend): use version id for version links when version_number is ambiguous - #8093

Open
TheRealAlexxx wants to merge 1 commit into
modrinth:mainfrom
TheRealAlexxx:fix-duplicate-version-slugs
Open

TheRealAlexxx wants to merge 1 commit into
modrinth:mainfrom
TheRealAlexxx:fix-duplicate-version-slugs

Conversation

@TheRealAlexxx

Copy link
Copy Markdown

Fix duplicate version slugs breaking version page routing

Fixes #8018

Problem

When two versions of a project share the same version_number (possible across
different loaders, e.g. 1.21.1-3.7.2 published for both Fabric and NeoForge),
the version page at /mod/<project>/version/<version_number> shows only one of
them, 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:

  • Two versions numbered 1.21.1-3.7.2 (Fabric fWlk6YEB, NeoForge fAIfWX6M),
    published within the same millisecond.
  • /mod/moonlight/version/1.21.1-3.7.2 loads the Fabric build's page; the
    NeoForge build has no working slug URL.

Root cause

In apps/frontend/src/plugins/shorthands.js, computeVersions decides which
version keeps the human-readable version_number slug when duplicates exist.
The tie-break sorts by date_published, but when versions are bulk-published
within 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 each version_number. Any version
whose number appears more than once is exposed under its unique version id
instead 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 computeVersions logic
against fixtures matching the live moonlight data (duplicate numbers,
same-millisecond publish):

  • Old logic: the duplicate slug attaches to only one version and the result
    depends on input ordering (bug reproduced).
  • New logic: duplicates resolve by version id; unique numbers keep slugs;
    result is independent of input ordering.
  • The modified file passes node --check, and the repo's full
    pnpm prepr:frontend:web pipeline (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.

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
@github-actions

Copy link
Copy Markdown
Contributor

Pull request changelog

App

Added

Changed

Deprecated

Removed

Fixed

Security

Website

Added

Changed

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

@mergify

mergify Bot commented Nov 10, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Clicking on Moonlight version 1.21.1-3.7.2 for neoforge takes you to the fabric downloads.

1 participant