Repository navigation
Reject lockfiles whose resolved versions violate declared specifiers - #23143
Closed
GautamKumarOffical wants to merge 2 commits into
Closed
GautamKumarOffical wants to merge 2 commits into
GautamKumarOffical wants to merge 2 commits into
Conversation
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.
Summary
Closes #23073.
Previously,
Lock::satisfiesonly checked whether declared requirements matched the lockfile's declared[package.metadata] requires-distand that resolved package names were present in the graph. It did not verify that the versions of the resolved dependency packages actually satisfied the declared PEP 440 version specifiers.As a result, if a lockfile experienced a conflicted merge or manual edit where declared specifiers in
pyproject.tomland metadata were bumped (e.g.anyio==3.7.0) while the resolved node remained atanyio==3.6.2,uv lock --lockedanduv lock --checkwould report that the lockfile was up-to-date and succeed.This change adds version specifier validation to
Lock::satisfies_requires_dist(and root requirements validation inLock::satisfies):SatisfiesResult::MismatchedPackageDependencieswhen a resolved dependency violates the declared specifiers, prompting--locked/--checkto error and re-resolution to trigger onuv lock.is_emptychecks onDependencyModifiersto bypass requirement preprocessing allocations when no overrides or excludes are configured.Test Plan
resolved_dependency_violating_specifier_fails_validationincrates/uv-lock/src/lock/mod.rs.lock_resolved_dependency_violating_specifier_fails_lockedincrates/uv/tests/project/lock.rsasserting--lockedand--checkfail when a resolved dependency violates the declared specifier, and thatuv lockupdates to the matching version.cargo test -p uv-lockcargo test -p uv --test it lock_resolved_dependency_violating_specifier_fails_lockedcargo clippy -p uv-lock -p uv-configuration