From 1ffe17bf624e95b1a794d8f002c0233006c3c610 Mon Sep 17 00:00:00 2001 From: Mondo Diaz Date: Tue, 3 Feb 2026 16:46:35 -0600 Subject: [PATCH] Fix artifact listing to include PyPI proxy cached packages The list_package_artifacts endpoint was only querying artifacts via the Upload table. PyPI proxy creates PackageVersion records but not Upload records, so cached packages would show stats (size, version count) but no artifacts in the listing. Now queries artifacts from both Upload and PackageVersion tables using a union, so PyPI-cached packages display their artifacts correctly. --- backend/app/routes.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/app/routes.py b/backend/app/routes.py index 5473cb8..8e3d367 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -4748,14 +4748,20 @@ def list_package_artifacts( if not package: raise HTTPException(status_code=404, detail="Package not found") - # Get distinct artifacts uploaded to this package via uploads table - artifact_ids_subquery = ( - db.query(func.distinct(Upload.artifact_id)) + # Get distinct artifacts for this package from both sources: + # 1. Upload table (traditional uploads) + # 2. PackageVersion table (PyPI proxy cached packages, version-based lookups) + upload_artifact_ids = ( + db.query(Upload.artifact_id) .filter(Upload.package_id == package.id) - .subquery() ) + version_artifact_ids = ( + db.query(PackageVersion.artifact_id) + .filter(PackageVersion.package_id == package.id) + ) + combined_artifact_ids = upload_artifact_ids.union(version_artifact_ids).subquery() - query = db.query(Artifact).filter(Artifact.id.in_(artifact_ids_subquery)) + query = db.query(Artifact).filter(Artifact.id.in_(combined_artifact_ids)) # Apply content_type filter if content_type: