Pull-through cache: `.whl.metadata` (PEP 658) requests raise `ValueError: True is not in list` on 3.29.0 — residual case of #1083
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Start in pulp_python/app/models.py at init_from_artifact_and_relative_path and pulp_python/app/utils.py at artifact_to_python_content_data and get_project_metadata_from_file; reproduce the cold-cache .whl.metadata request with curl or uv. Trace the companion metadata path and verify it no longer invokes the extractor for an unsupported extension, while the request either serves metadata or returns a clean 404 without the ValueError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
pulp_python3.29.0pulpcore3.108.0- Installation: container image (Pulp operator on Kubernetes)
Describe the bug
On a pull-through PyPI distribution, when a client requests <wheel>.whl.metadata (PEP 658), pulp-content raises ValueError: True is not in list in pulp_python/app/utils.py:get_project_metadata_from_file and returns a 5xx / aborted stream. A direct GET also surfaces a misleading 404 with an upstream URL that doesn't exist (https://pypi.org/simple/<package>/<wheel>.whl.metadata — PEP 658 metadata files live next to the wheel on files.pythonhosted.org/packages/<hash>/..., not under the simple index path).
This appears to be a residual case of #1083. PR #1086 fixed the .whl fetch path by passing suffix=filename into the temp file, so endswith(".whl") matches. But when the requested artifact is the .whl.metadata companion, init_from_artifact_and_relative_path is still called, path.name ends in .metadata, the temp file ends in .metadata, and DIST_EXTENSIONS has no .metadata entry — so .index(True) raises.
To Reproduce
- Configure a pull-through PyPI distribution:
pulp python remote create --name pypi --url https://pypi.org/ --policy on_demand
pulp python distribution create --name pypi-proxy --base-path pypi --remote pypi
- From a clean state (no cached package), request the PEP 658 metadata file directly:
curl -sk -o - -w "HTTP %{http_code}\n" \
"https://<pulp>/pulp/content/<domain>/pypi/simple/ruff/ruff-0.12.12-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata"
Equivalent: run uv lock / uv sync against this distribution from a cold uv cache — uv issues .whl.metadata requests per PEP 658.
3. Observe a 404 to the client and the following traceback in pulp-content logs:
File "pulpcore/content/handler.py", line 1033, in _save_artifact
content = c_type.init_from_artifact_and_relative_path(artifact, rel_path)
File "pulp_python/app/models.py", line 223, in init_from_artifact_and_relative_path
data = artifact_to_python_content_data(path.name, artifact, domain=get_domain())
File "pulp_python/app/utils.py", line 273, in artifact_to_python_content_data
metadata = get_project_metadata_from_file(temp_file.name)
File "pulp_python/app/utils.py", line 195, in get_project_metadata_from_file
pkg_type_index = [filename.endswith(ext) for ext in extensions].index(True)
ValueError: True is not in list
Expected behavior
Either:
- The
.metadatacompanion is served from upstream (fetched alongside / extracted from the wheel) so PEP 658 works through the pull-through cache, or - The request returns a clean 404 without invoking the python-package metadata extractor on a non-package file.
In both cases get_project_metadata_from_file should not be called with a filename whose extension isn't in DIST_EXTENSIONS.
Additional context
- Original report and partial fix: #1083, PR #1086 ("Fix pull-through metadata serving and saving", merged 2026-02-06; backported to 3.24 in #1089).
- Related: #1101 (PR #1102) — metadata file mismatched against wheel.
- 3.29.0 source for
artifact_to_python_content_dataconfirms thesuffix=filenamefix from #1086 is present, so the.whlpath works; the.whl.metadatapath bypasses that protection becausefilenameitself ends in.metadata. - Likely fix direction: short-circuit the companion
.metadatacase beforeartifact_to_python_content_datais called (e.g. ininit_from_artifact_and_relative_pathwhenrelative_pathends in.metadata), since those bytes already are the metadata and don't need extracting. - Effect on clients:
uvresolutions against the pull-through distribution silently report "only<old-cached-version>is available" because per-version metadata fetches all crash server-side; only versions whose metadata happens to already be cached in Postgres remain visible.
- Ngôn ngữ chính
- Python
- Star
- 49
- Fork
- 88
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 31
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pulp/pulp_python
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
pulp/pulp_python#1381 ·
-
Feature Triage-Needed
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
pulp/pulp_python#1371 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
pulp/pulp_python#1360 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
pulp/pulp_python#1358 ·
-
Feature
pulp/pulp_python#1340 · 1 người được giao ·
Tất cả issue của pulp/pulp_python
Issue tương tự
-
link-check link-check:sphinx-theme
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
OpenHands/extensions#626 · 1 bình luận ·
-
Change observation tooltip text Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
CSCfi/sd-search-api#39 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100