Skip to content

Fix: Preserve version ordering in VersionResponse#858

Open
drawliin wants to merge 1 commit intoaboutcode-org:mainfrom
drawliin:fix/version-response-ordering
Open

Fix: Preserve version ordering in VersionResponse#858
drawliin wants to merge 1 commit intoaboutcode-org:mainfrom
drawliin:fix/version-response-ordering

Conversation

@drawliin
Copy link
Copy Markdown

@drawliin drawliin commented Mar 27, 2026

Closes #857

What this changes

This updates packagedb.package_managers.VersionAPI.get_until() to preserve the original version order returned by fetch().

Previously, VersionResponse.valid_versions and newer_versions were built using sets. That removed duplicates, but it also lost the original ordering of versions.

This change switches the returned values to ordered lists and keeps deduplication with internal seen sets.

Why

There is already a related note in packagedb/package_managers.py:

# FIXME: DO NOT use set() for storing version lists: they lose the original ordering

Preserving version order makes the behavior more predictable while still avoiding duplicate version values.

Tests

Updated packagedb/tests/test_package_managers.py to:

  • expect ordered results from get_until()
  • add a regression test that checks both order preservation and deduplication

Signed-off-by: drawlin <itshoussameddine@gmail.com>
@drawliin drawliin changed the title Preserve version ordering in VersionResponse Fix: Preserve version ordering in VersionResponse Mar 31, 2026
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.

Preserve version ordering in packagedb VersionResponse

1 participant