Avoid panic when re-locking with precise commit #5863
Merged
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.
Summary
Very subtle bug. The scenario is as follows:
We resolve:
elmer-circuitbuilder = { git = "https://github.com/ElmerCSC/elmer_circuitbuilder.git" }
The user then changes the request to:
elmer-circuitbuilder = { git = "https://github.com/ElmerCSC/elmer_circuitbuilder.git", rev = "44d2f4b19d6837ea990c16f494bdf7543d57483d" }
When we go to re-lock, we note two facts:
44d2f4b19d6837ea990c16f494bdf7543d57483d
.44d2f4b19d6837ea990c16f494bdf7543d57483d
is (whatever we grab from the lockfile).In the resolver, we then ask for the metadata for
44d2f4b19d6837ea990c16f494bdf7543d57483d
. It's already in the cache, so we return it; thus, we never add the44d2f4b19d6837ea990c16f494bdf7543d57483d
->44d2f4b19d6837ea990c16f494bdf7543d57483d
mapping to the Git resolver, because we never have to resolve it.This would apply for any case in which a requested tag or branch was replaced by its precise SHA. Replacing with a different commit is fine.
It only applied to
tool.uv.sources
, and not PEP 508 URLs, because the underlying issue is that we aren't consistent about "automatically" extracting the precise commit from a Git reference.Closes #5860.