mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-20 11:56:03 +00:00
Revert normalization of trailing slashes on index URLs (#14511)
Reverts: - #14349 - #14346 - #14245 Retains the test cases. Includes a `find-links` test case. Supersedes - https://github.com/astral-sh/uv/pull/14387 - https://github.com/astral-sh/uv/pull/14503 We originally got a report at https://github.com/astral-sh/uv/issues/13707 that inclusion of a trailing slash on an index URL was causing lockfile churn despite having no semantic meaning and resolved the issue by adding normalization that stripped trailing slashes at parse time. We then discovered that, while there are not semantic differences for trailing slashes on Simple API index URLs, there are differences for some flat (or find links) indexes. As reported in https://github.com/astral-sh/uv/issues/14367, the change in https://github.com/astral-sh/uv/pull/14245 caused a regression for at least one user. We attempted to fix the regression via a few approaches. https://github.com/astral-sh/uv/pull/14387 attempted to differentiate between Simple API and flat index URL parsing, but failed to account for the `Deserialize` implementation, which always assumed Simple API-style index URLs and incorrectly trimmed trailing slashes in various cases where we deserialized the `IndexUrl` type from a file. I attempted to resolve this by performing a larger refactor, but it ended up being quite painful. In particular, the `Index` type was a blocker — we don't know the `IndexUrl` variant until we've parsed the `IndexFormat` and having a multi-stage deserializer is not appealing but adding a new intermediate type (i.e., `RawIndex`) is painful due to the pervasiveness of `Index`. Given that we've regressed behavior here and there's not a straight-forward fix, we're reverting the normalization entirely. https://github.com/astral-sh/uv/pull/14503 attempted to perform normalization at compare-time, but that means we'd fail to invalidate the lockfile when the a trailing slash was added or removed and given that a trailing slash has semantic meaning for a find-links URL... we'd have another correctness problem. After this revert, we'll retain all index URLs verbatim. The downside to this approach is that we'll be adding a bunch of trailing slashes back to lockfiles that we previously normalized out, and we'll be reverting our fix for users with inconsistent trailing slashes on their index URLs. Users affected by the original motivating issue should use consistent trailing slashes on their URLs, as they do frequently have semantic meaning. We may want to revisit normalization and type aware index URL parsing as part of a larger change. Closes https://github.com/astral-sh/uv/issues/14367
This commit is contained in:
parent
afcbcc7498
commit
2709c441a8
8 changed files with 344 additions and 266 deletions
|
|
@ -1478,11 +1478,9 @@ impl Lock {
|
|||
if let Source::Registry(index) = &package.id.source {
|
||||
match index {
|
||||
RegistrySource::Url(url) => {
|
||||
// Normalize URL before validating.
|
||||
let url = url.without_trailing_slash();
|
||||
if remotes
|
||||
.as_ref()
|
||||
.is_some_and(|remotes| !remotes.contains(&url))
|
||||
.is_some_and(|remotes| !remotes.contains(url))
|
||||
{
|
||||
let name = &package.id.name;
|
||||
let version = &package
|
||||
|
|
@ -1490,11 +1488,7 @@ impl Lock {
|
|||
.version
|
||||
.as_ref()
|
||||
.expect("version for registry source");
|
||||
return Ok(SatisfiesResult::MissingRemoteIndex(
|
||||
name,
|
||||
version,
|
||||
url.into_owned(),
|
||||
));
|
||||
return Ok(SatisfiesResult::MissingRemoteIndex(name, version, url));
|
||||
}
|
||||
}
|
||||
RegistrySource::Path(path) => {
|
||||
|
|
@ -1799,7 +1793,7 @@ pub enum SatisfiesResult<'lock> {
|
|||
/// The lockfile is missing a workspace member.
|
||||
MissingRoot(PackageName),
|
||||
/// The lockfile referenced a remote index that was not provided
|
||||
MissingRemoteIndex(&'lock PackageName, &'lock Version, UrlString),
|
||||
MissingRemoteIndex(&'lock PackageName, &'lock Version, &'lock UrlString),
|
||||
/// The lockfile referenced a local index that was not provided
|
||||
MissingLocalIndex(&'lock PackageName, &'lock Version, &'lock Path),
|
||||
/// A package in the lockfile contains different `requires-dist` metadata than expected.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue