Bug 2033940

Summary: Error: AttributeError: 'NoneType' object has no attribute 'cast' thrown while listing repository versions
Product: Red Hat Satellite Reporter: Krutika Kinge <kkinge>
Component: PulpAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Stephen Wadeley <swadeley>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.10.1CC: ahumbe, dkliban, ggainey, inwa, rchan, swadeley
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pulpcore-3.16.4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:31:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Krutika Kinge 2021-12-19 02:22:30 UTC
Description of problem:

After upgrade to Satellite 6.10, 'Actions::Katello::OrphanCleanup::RemoveOrphans' task is failing. Following errors are thrown while listing repository versions:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/log/messages

Dec 16 07:34:12 xxx pulpcore-api: pulp [aaa-aaaaa-aaaaaa-aaaaaa-aaaaaaaa]: django.request:ERROR: Internal Server Error: /pulp/api/v3/repositories/rpm/rpm/c6963cf8-4a81-4b18-94e9-651ec8a07319/versions/
Dec 16 07:34:12 xxx pulpcore-api: Traceback (most recent call last):
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
Dec 16 07:34:12 xxx pulpcore-api: response = get_response(request)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
Dec 16 07:34:12 xxx pulpcore-api: response = self.process_exception_by_middleware(e, request)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
Dec 16 07:34:12 xxx pulpcore-api: response = wrapped_callback(request, *callback_args, **callback_kwargs)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
Dec 16 07:34:12 xxx pulpcore-api: return view_func(*args, **kwargs)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/viewsets.py", line 125, in view
Dec 16 07:34:12 xxx pulpcore-api: return self.dispatch(request, *args, **kwargs)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/views.py", line 509, in dispatch
Dec 16 07:34:12 xxx pulpcore-api: response = self.handle_exception(exc)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/views.py", line 469, in handle_exception
Dec 16 07:34:12 xxx pulpcore-api: self.raise_uncaught_exception(exc)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
Dec 16 07:34:12 xxx pulpcore-api: raise exc
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/views.py", line 506, in dispatch
Dec 16 07:34:12 xxx pulpcore-api: response = handler(request, *args, **kwargs)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/mixins.py", line 43, in list
Dec 16 07:34:12 xxx pulpcore-api: return self.get_paginated_response(serializer.data)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/serializers.py", line 745, in data
Dec 16 07:34:12 xxx pulpcore-api: ret = super().data
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/serializers.py", line 246, in data
Dec 16 07:34:12 xxx pulpcore-api: self._data = self.to_representation(self.instance)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/serializers.py", line 664, in to_representation
Dec 16 07:34:12 xxx pulpcore-api: self.child.to_representation(item) for item in iterable
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/serializers.py", line 664, in <listcomp>
Dec 16 07:34:12 xxx pulpcore-api: self.child.to_representation(item) for item in iterable
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/rest_framework/serializers.py", line 515, in to_representation
Dec 16 07:34:12 xxx pulpcore-api: ret[field.field_name] = field.to_representation(attribute)
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/pulpcore/app/serializers/repository.py", line 360, in to_representation
Dec 16 07:34:12 xxx pulpcore-api: item_dict = {"count": count_detail.count, "href": count_detail.content_href}
Dec 16 07:34:12 xxx pulpcore-api: File "/usr/lib/python3.6/site-packages/pulpcore/app/models/repository.py", line 1027, in content_href
Dec 16 07:34:12 xxx pulpcore-api: ctype_model = Content.objects.filter(pulp_type=self.content_type).first().cast().__class__
Dec 16 07:34:12 xxx pulpcore-api: AttributeError: 'NoneType' object has no attribute 'cast'
Dec 16 07:34:12 xxx pulpcore-api: pulp [aaa-aaaaa-aaaaaa-aaaaaa-aaaaaaaa]:  - - [16/Dec/2021:06:34:12 +0000] "GET /pulp/api/v3/repositories/rpm/rpm/c6963cf8-4a81-4b18-94e9-651ec8a07319/versions/?limit=2000&offset=0 HTTP/1.1" 500 27 "-" "OpenAPI-Generator/3.13.3/ruby"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

How reproducible:
In customer environment

Additional info:
Upstream link: https://pulp.plan.io/issues/9481

Comment 1 Dennis Kliban 2022-03-30 17:47:27 UTC
This is fixed in pulpcore 3.14, 3.15, 3.16, 3.17, 3.18 .

Comment 9 errata-xmlrpc 2022-07-05 14:31:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.11 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5498