From cc701f42c6f284f8a3a8a12d3433c76caa667f47 Mon Sep 17 00:00:00 2001 From: Jitka Halova Date: Thu, 30 Apr 2026 10:35:17 +0200 Subject: [PATCH] Fix pull-through caching failing for improper named packages --- CHANGES/1040.bugfix | 1 + pulp_python/app/utils.py | 2 +- .../tests/functional/api/test_full_mirror.py | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 CHANGES/1040.bugfix diff --git a/CHANGES/1040.bugfix b/CHANGES/1040.bugfix new file mode 100644 index 000000000..e06ea3508 --- /dev/null +++ b/CHANGES/1040.bugfix @@ -0,0 +1 @@ +Fixed pull-through caching failing for packages with bad names. diff --git a/pulp_python/app/utils.py b/pulp_python/app/utils.py index 178df1c93..17602d696 100644 --- a/pulp_python/app/utils.py +++ b/pulp_python/app/utils.py @@ -458,7 +458,7 @@ def filter_release(self, project_name, version): try: version = parse(version) - except InvalidVersion: + except (InvalidVersion, TypeError): return False include_range = self._filter_includes.get("range", {}) diff --git a/pulp_python/tests/functional/api/test_full_mirror.py b/pulp_python/tests/functional/api/test_full_mirror.py index ea07bab2d..76e343aae 100644 --- a/pulp_python/tests/functional/api/test_full_mirror.py +++ b/pulp_python/tests/functional/api/test_full_mirror.py @@ -138,3 +138,23 @@ def test_pull_through_with_repo( assert r.status_code == 200 tasks = pulpcore_bindings.TasksApi.list(reserved_resources=repo.prn) assert tasks.count == 3 + + +@pytest.mark.parallel +def test_pull_through_filtering_bad_names(python_remote_factory, python_distribution_factory): + """Tests that pull-through handles packages with invalid names gracefully.""" + # ipython version 0.13.X has improper named bdist_wininst, e.g ipython-0.13.py2-win-amd64.exe + # pypi-simple expects the platform to go before the pyversion (for .exe), so when parsed the + # version and package type will be None. + remote = python_remote_factory(url=PYPI_URL, includes=["ipython"]) + distro = python_distribution_factory(remote=remote.pulp_href) + + url = f"{distro.base_url}simple/ipython/" + response = requests.get(url) + + assert response.status_code == 200 + + project_page = ProjectPage.from_response(response, "ipython") + # Should have no packages with None version (they get filtered out) + assert len(project_page.packages) > 0 + assert all(package.version is not None for package in project_page.packages)