From a084a04850ed977d5d7dfaeabcc878c1af011e2e Mon Sep 17 00:00:00 2001 From: git-hyagi <45576767+git-hyagi@users.noreply.github.com> Date: Thu, 9 Jul 2026 14:37:06 -0300 Subject: [PATCH] Fix RepositoryVersion.remove_content using wrong queryset for lazy content The remove_content method was incorrectly using the unfiltered `content` queryset instead of `to_remove` when deleting or marking RepositoryContent entries as removed. This caused all content to be removed from the repository version rather than only the specified lazy content. Fixes: https://github.com/pulp/pulpcore/issues/7851 Co-Authored-By: Claude Opus 4.6 (1M context) --- CHANGES/7851.bugfix | 1 + pulpcore/app/models/repository.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 CHANGES/7851.bugfix diff --git a/CHANGES/7851.bugfix b/CHANGES/7851.bugfix new file mode 100644 index 0000000000..e6db431653 --- /dev/null +++ b/CHANGES/7851.bugfix @@ -0,0 +1 @@ +Fixed `RepositoryVersion.remove_content` incorrectly removing all content instead of only the specified lazy content. diff --git a/pulpcore/app/models/repository.py b/pulpcore/app/models/repository.py index 5470fb5d23..f0d711b649 100644 --- a/pulpcore/app/models/repository.py +++ b/pulpcore/app/models/repository.py @@ -1231,13 +1231,13 @@ def remove_content(self, content): # Undo addition by deleting the RepositoryContent. RepositoryContent.objects.filter( repository=self.repository, - content_id__in=content, + content_id__in=to_remove, version_added=self, version_removed=None, ).delete() q_set = RepositoryContent.objects.filter( - repository=self.repository, content_id__in=content, version_removed=None + repository=self.repository, content_id__in=to_remove, version_removed=None ) q_set.update(version_removed=self)