Skip to content

Failed mirroring when using latest_release plugin #1775

@imjustvisiting

Description

@imjustvisiting

Certain packages never get mirrored when using the latest_release plugin do to an unhandled exception raised by the "parse()" function from packaging.version.

nltk package is an example of a package that is never mirrored when the latest_release plugin is used to filter the last "n" versions of each package. In that specific case, the nltk package has a release version "2.0.1rc2-git" that returns the following when packaging.version.parse() is called:

Traceback (most recent call last):
    print(parse("2.0.1rc2-git"))
          ^^^^^^^^^^^^^^^^^^^^^
  File "lib64/python3.12/site-packages/packaging/version.py", line 56, in parse
    return Version(version)
           ^^^^^^^^^^^^^^^^
  File "lib64/python3.12/site-packages/packaging/version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
packaging.version.InvalidVersion: Invalid version: '2.0.1rc2-git'

Because this exception is not handled, the plugin always returns an empty list of possible package releases -- resulting in nothing being mirrored.

The failing code is in bandersnatch_filter_plugins/latest_name.py:

for r in releases.keys():
    versions_pair: Iterator[tuple[Version, str]] = map(
        lambda v: (parse(v), v), releases.keys()
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions