unify find-latest-version #3336
Open
syphar wants to merge 1 commit into
Open
Conversation
b608de7 to
f428def
Compare
e48e8fe to
dcfd5d9
Compare
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.
Fixes #3290 by unifying "latest version" logic across all places.
This also leads to some behavioural changes, which are mostly fine IMO, they become tricky when all releases of a crate are yanked. In this "all-yanked" case, we will start treating a crate with only yanked releases as "hidden / deleted" in some cases. Personally this feels more correct, but I'm happy to discuss.
AI summary of the before/after:
Behavioural changes in
fix-latest-releaseThis branch consolidates three "latest release" decisions onto a single canonical picker:
/crate/{name}/latest/...URL resolution (viamatch_version)is_latest_version/ "Go to latest" buttoncrates.latest_version_idcolumn (read by sitemaps, home page lists, crates.io search bridge, "I'm feeling lucky", watcher rebuilds, repository stats)The picker is:
The table below shows how each surface changes per scenario.
Legend
mainScenario 1 — All releases yanked
/crate/foo/latest/...latest_releaseResult::?propagates "crate without releases" → 500 🐛None; "Go to latest" button hidden ✅crates.latest_version_idNULL✅crate_countScenario 2 — Yanked stable + non-yanked prerelease (the bug-report case)
Example:
[0.2.0 yanked, 0.2.0-pre.1 not yanked]./crate/foo/latest/...0.2.0-pre.1)latest_release0.2.0) 🐛is_latest_versionon/0.2.0-pre.1/false→ "Go to latest" button shown 🐛true→ button hidden ✅/latest/→ same prerelease page (loop) 🐛crates.latest_version_idScenario 3 — Only non-yanked releases are in-progress
Example: brand-new crate with one release whose build hasn't finished.
/crate/foo/latest/...latest_releaseNone→ 500 🐛None→ button hidden ✅crates.latest_version_idNULLNULL✔^1.0semver query (range-matching, not/latest/)Scenario 4 — Failed build is the highest non-yanked release
/crate/foo/latest/...latest_releaselatest_path(button target)crate_details_url()(build wasn't successful)crate_details_url()✔crates.latest_version_idrustdoc_status = false)Scenario 5 — Specific yanked version (direct exact-match URL)
Example:
/crate/foo/0.2.0/...where0.2.0is yanked.is_latest_version/latest/)Summary
^1.0, etc.) are unchanged.The picker is now structurally the same across
/latest/, the topbar, andlatest_version_id— disagreement isn't just unlikely, it's impossible by construction.Backfill
Existing
crates.latest_version_idrows on production may still point at yanked or otherwise stale picks. They self-heal next time any build event triggersupdate_latest_version_idfor that crate. For an eager rewrite, run the existingdocs_rs_adminbackfill command.