Skip to content

fix(semver): keep prerelease when comparing versions - #7

Merged
NewtTheWolf merged 2 commits into
mainfrom
fix/semver-prerelease-latest-version
Aug 18, 2026
Merged

fix(semver): keep prerelease when comparing versions#7
NewtTheWolf merged 2 commits into
mainfrom
fix/semver-prerelease-latest-version

Conversation

@NewtTheWolf

Copy link
Copy Markdown
Contributor

Reported on Discord: the PostgreSQL plugin page shows beta.5 as the latest release while beta.7 is published and also visible on the page.

Root cause

compareSemver coerced both sides with semver.coerce(), which drops the prerelease. Every 1.0.0-beta.N collapsed to 1.0.0, so they all compared equal. persistRelease only bumps latestVersion when compareSemver(new, current) > 0, so once a prerelease series started, latestVersion froze at whichever beta landed first — later betas kept ingesting as normal release rows, which is why both versions appear on the page.

The same bug ranked a stable 2.0.0 equal to its own 2.0.0-rc.1, so a GA release would not have replaced its release candidate as latest either.

Not just cosmetic

The plugin detail page sorts releases by createdAt for the download section (beta.7), but the download button links to /api/plugins/:slug/latest, which resolves through latestVersion. Verified against production: that endpoint returns asset URLs under /download/v1.0.0-beta.5/. The desktop client uses the same endpoint for install and update, so users were getting beta.5 while the page advertised beta.7.

Fix

semver.coerce(x, { includePrerelease: true }). The coerce() call is still needed for legacy lax tags (v1.2), and those keep working.

compareSemver had no test coverage at all, which is how this shipped. Added a block covering prerelease ordering, stable-vs-own-prerelease, plain releases, legacy lax tags, and unparseable input — verified it fails on exactly the two prerelease cases without the fix.

After merge

Deploying only fixes future ingests; the stored latestVersion for postgresql stays wrong. Repairing it needs no SQL — Admin → Plugins → postgresql → Replay webhook re-runs persistRelease against the upstream latest release, which then passes the corrected comparison and writes 1.0.0-beta.7.

Scanned all 13 plugins on the production registry: postgresql is the only one currently mismatched, since it is the only one publishing prereleases.

semver.coerce() drops the prerelease, so every 1.0.0-beta.N coerced to
1.0.0 and compared equal. persistRelease only bumps latestVersion when
compareSemver(new, current) > 0, so a plugin's latestVersion froze at
whichever prerelease of a series landed first while later betas kept
ingesting as ordinary release rows.

Live effect on the postgresql plugin: latestVersion stuck at
1.0.0-beta.5 with beta.6 and beta.7 published. The detail page sorts
releases by createdAt and showed beta.7 next to the download button,
but /api/plugins/:slug/latest resolves through latestVersion and served
beta.5 binaries — same path the desktop client uses to install and
update.

Same bug ranked a stable 2.0.0 equal to its own 2.0.0-rc.1.

compareSemver had no test coverage at all; added a block that fails on
both counts without the fix.
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
tabularium-docs Skipped Skipped Aug 18, 2026 4:16pm
tabularium-website Skipped Skipped Aug 18, 2026 4:16pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – tabularium-docs August 18, 2026 16:16 Inactive
@vercel
vercel Bot temporarily deployed to Preview – tabularium-website August 18, 2026 16:16 Inactive
@NewtTheWolf
NewtTheWolf merged commit f30286e into main Aug 18, 2026
9 checks passed
@NewtTheWolf
NewtTheWolf deleted the fix/semver-prerelease-latest-version branch August 18, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant