diff --git a/CHANGES/content-assert.bugfix b/CHANGES/content-assert.bugfix new file mode 100644 index 0000000000..a562ce863f --- /dev/null +++ b/CHANGES/content-assert.bugfix @@ -0,0 +1 @@ +Fixed an assertion on all content being added/removed in a repository version is of the same domain. diff --git a/pulpcore/app/models/repository.py b/pulpcore/app/models/repository.py index 5fbff679cb..35a06809b9 100644 --- a/pulpcore/app/models/repository.py +++ b/pulpcore/app/models/repository.py @@ -984,7 +984,11 @@ def add_content(self, content): if self.complete: raise ResourceImmutableError(self) - assert not content.exclude(pulp_domain_id=get_domain_pk()).exists() + assert ( + not Content.objects.filter(pk__in=content) + .exclude(pulp_domain_id=get_domain_pk()) + .exists() + ) repo_content = [] to_add = set(content.values_list("pk", flat=True)) - set( self.content.values_list("pk", flat=True) @@ -1026,7 +1030,11 @@ def remove_content(self, content): if not content or not content.count(): return - assert not content.exclude(pulp_domain_id=get_domain_pk()).exists() + assert ( + not Content.objects.filter(pk__in=content) + .exclude(pulp_domain_id=get_domain_pk()) + .exists() + ) # Normalize representation if content has already been added in this version. # Undo addition by deleting the RepositoryContent.