Project

Profile

Help

Issue #8396

closed

AttributeError: 'NoneType' object has no attribute 'get_host'

Added by ipanova@redhat.com over 3 years ago. Updated over 3 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 95
Quarter:

Description

The traceback is from pulp_container but the root cause likely is in pulp core. In some places in the context we send request None

[ipanova@fluffy pulpcore]$ git grep '{"request": None}'
pulpcore/app/serializers/exporter.py:                exported_resource.content_object, context={"request": None}
pulpcore/app/serializers/user.py:            serializer = viewset.serializer_class(obj.content_object, context={"request": None})
pulpcore/app/viewsets/user.py:            serializer = GroupUserSerializer(page, context={"request": None}, many=True)
pulpcore/app/viewsets/user.py:        serializer = GroupUserSerializer(user, context={"request": None})
[ipanova@fluffy pulpcore]$ 

(pulp) [vagrant@pulp3-source-fedora32 ~]$ http :24817/pulp/api/v3/groups/4/object_permissions/
HTTP/1.1 500 Internal Server Error
Access-Control-Expose-Headers: Correlation-ID
Connection: close
Content-Length: 27
Content-Type: text/html
Correlation-ID: 2598b579ba66489197784f4ef0c11e5d
Date: Fri, 12 Mar 2021 12:57:19 GMT
Server: gunicorn/20.0.4
Vary: Cookie
X-Frame-Options: SAMEORIGIN

<h1>Server Error (500)</h1>


(pulp) [vagrant@pulp3-source-fedora32 ~]$ pjournal 
-- Logs begin at Wed 2021-03-10 13:02:42 UTC. --
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]:   File "/usr/local/lib/pulp/lib64/python3.8/site-packages/rest_framework/serializers.py", line 548, in data
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]:     ret = super().data
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]:   File "/usr/local/lib/pulp/lib64/python3.8/site-packages/rest_framework/serializers.py", line 246, in data
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]:     self._data = self.to_representation(self.instance)
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]:   File "/usr/local/lib/pulp/lib64/python3.8/site-packages/rest_framework/serializers.py", line 515, in to_representation
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]:     ret[field.field_name] = field.to_representation(attribute)
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]:   File "/home/vagrant/devel/pulp_container/pulp_container/app/serializers.py", line 135, in to_representation
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]:     return f"{request.get_host()}/{value}"
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]: AttributeError: 'NoneType' object has no attribute 'get_host'
Mar 12 12:57:19 pulp3-source-fedora32.fluffy.example.com gunicorn[22822]: pulp [2598b579ba66489197784f4ef0c11e5d]: 127.0.0.1 - admin [12/Mar/2021:12:57:19 +0000] "GET /pulp/api/v3/groups/4/object_permissions/ HTTP/1.1" 500 27 "-" "HTTPie/2.4.0"


Related issues

Related to Pulp - Issue #8190: AttributeError: 'NoneType' object has no attribute 'query_params'CLOSED - DUPLICATElmjachkyActions

Also available in: Atom PDF