Skip to content

util/resolve: sort versions in APIClient.Versions - #387

Merged
cuixq merged 1 commit into
google:mainfrom
miraeti:fix/385-api-client-versions-sort
Aug 27, 2026
Merged

util/resolve: sort versions in APIClient.Versions#387
cuixq merged 1 commit into
google:mainfrom
miraeti:fix/385-api-client-versions-sort

Conversation

@miraeti

@miraeti miraeti commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #385.

Supersedes #386 (closed after a head-branch rename)

Continuing the review thread with @cuixq, who suggested sorting at the API client layer and documenting on Client.Versions that the versions should be sorted.

Problem

APIClient.Versions returned versions in the order returned by the deps.dev API, which is not ascending (for PyPI, at least, it is lexicographic, where "9.1.0" comes after "84.0.0"). The PyPI resolver iterates the version list in descending order, relying on it being sorted ascending, so unpinned transitive requirements resolved to the lexicographic maximum (e.g. setuptools 9.1.0 instead of 84.0.0).

Fix

Sort the versions in APIClient.Versions, the layer that converts the API response, and document the ordering contract on Client.Versions.

Test

TestVersions feeds a lexicographically ordered PyPI version list to APIClient.Versions and asserts the ascending order, and verified the test fails without the fix.

@cuixq
cuixq merged commit dc936a4 into google:main Aug 27, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PyPI resolver pins lexicographically-greatest version (e.g. setuptools 9.1.0) instead of highest semver when using the deps.dev API as data source

2 participants