Repository navigation
Description
Summary
When LenientRequirement fixes a missing dot before * on a three-part version whose middle segment has two digits, it drops the leading digits and rewrites the version to a different release series. For example, requests==2.32.3* in pyproject.toml is rewritten to requests==2.3.* and resolves requests==2.3.0 without warning by default (whereas single-digit requests==2.2.0* is rewritten to requests==2.2.0.* and resolves requests==2.2.0).
Minimal reproduction:
mkdir -p /tmp/example && cd /tmp/example
cat > pyproject.toml <<'EOF'
[project]
name = "example"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = ["requests==2.32.3*"]
EOF
uv pip compile pyproject.tomlOutput:
Resolved 1 package in 7ms
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml
requests==2.3.0
# via example (pyproject.toml)
(uv lock and uv sync on the same pyproject.toml also resolve and install requests==2.3.0.)
Expected requests==2.32.3* to be rewritten to requests==2.32.3.* (resolving requests==2.32.3) or rejected as an invalid version specifier, rather than silently resolving requests==2.3.0.
Verbose output (uv pip compile pyproject.toml -v):
DEBUG Found workspace root: /tmp/example
DEBUG Adding root workspace member: /tmp/example
DEBUG Skipping `pyproject.toml` in `/tmp/example` (no `[tool]` section)
...
DEBUG uv 0.13.10 (x86_64-unknown-linux-gnu)
...
WARN Fixing invalid requirement by inserting missing dot (before: `requests==2.32.3*`; after: `requests==2.3.*`)
DEBUG Found static `requires-dist` for: /tmp/example
DEBUG Solving with installed Python version: 3.14.10
DEBUG Solving with target Python version: >=3.14.10
DEBUG Adding direct dependency: requests>=2.3.dev0, <2.4.dev0
DEBUG Found fresh response for: https://pypi.org/simple/requests/
DEBUG Searching for a compatible version of requests (>=2.3.dev0, <2.4.dev0)
DEBUG Found fresh response for: https://files.pythonhosted.org/packages/f7/51/7aa1e337862118bee783c0249debd64cb07b8fbdfef154b1e185754b02d5/requests-2.3.0-py2.py3-none-any.whl.metadata
DEBUG Selecting: requests==2.3.0 [compatible] (requests-2.3.0-py2.py3-none-any.whl)
DEBUG Tried 1 versions: requests 1
DEBUG marker environment resolution took 0.001s
Resolved 1 package in 3ms
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml
requests==2.3.0
# via example (pyproject.toml)
In crates/uv-pypi-types/src/lenient_requirement.rs, the "inserting missing dot" fixup uses regex!(r"(\d\.\d)+\*").replace_all(input, r"${1}.*"): because + is outside capture group 1, 2.32.3* matches (\d\.\d) twice (2.3 then 2.3) and ${1} retains only the last group (2.3).
Platform
Linux 6.1.0-56-cloud-amd64 x86_64 GNU/Linux
Version
uv 0.13.10 (x86_64-unknown-linux-gnu) and main (e3e7c1eacb980339352a5ad69affcd3b6c206c92)
Python version
Python 3.14.10
We found this while fuzzing.
Credit: https://ucsbplse.github.io/
Activity