Actions
Issue #2755
closedWorkers API endpoint unusable due to improperly configured lookup_field
Start date:
Due date:
Estimated time:
Severity:
3. High
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 20
Quarter:
Description
One can't access the list of workers or it's detail. When accesed detail 404 raises for example on url :
http://dev.example.com/api/v3/workers/reserved_resource_worker_2@dev.example.com
If changed lookup field on serializer and viewset to pk everything work as excepted.
Error on list view:
Environment:
Request Method: GET
Request URL: http://dev.example.com/api/v3/workers/
Django Version: 1.8.18
Python Version: 3.5.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_filters',
'rest_framework',
'pulp.app',
'crispy_forms',
'django_extensions']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/Django-1.8.18-py3.5.egg/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/Django-1.8.18-py3.5.egg/django/views/decorators/csrf.py" in wrapped_view
58. return view_func(*args, **kwargs)
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/viewsets.py" in view
86. return self.dispatch(request, *args, **kwargs)
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/views.py" in dispatch
489. response = self.handle_exception(exc)
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/views.py" in handle_exception
449. self.raise_uncaught_exception(exc)
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/views.py" in dispatch
486. response = handler(request, *args, **kwargs)
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/mixins.py" in list
45. return self.get_paginated_response(serializer.data)
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/serializers.py" in data
739. ret = super(ListSerializer, self).data
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/serializers.py" in data
263. self._data = self.to_representation(self.instance)
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/serializers.py" in to_representation
657. self.child.to_representation(item) for item in iterable
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/serializers.py" in <listcomp>
657. self.child.to_representation(item) for item in iterable
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/serializers.py" in to_representation
501. ret[field.field_name] = field.to_representation(attribute)
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/djangorestframework-3.6.3-py3.5.egg/rest_framework/relations.py" in to_representation
390. raise ImproperlyConfigured(msg % self.view_name)
Exception Type: ImproperlyConfigured at /api/v3/workers/
Exception Value: Could not resolve URL for hyperlinked relationship using view name "workers-detail". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field.
Updated by mhrivnak over 7 years ago
- Sprint/Milestone set to 38
- Triaged changed from No to Yes
Updated by bizhang over 7 years ago
I'm not sure if 'pk' is the correct lookup_field in this case. Since we want the url to the worker to contain the name of the worker instead of an uuid.
Updated by bizhang over 7 years ago
- Status changed from NEW to POST
- Assignee set to bizhang
Root cause was the .
character in the worker name, updating the viewset lookup regex to not exclude the .
fixes this issue
Added by werwty over 7 years ago
Added by werwty over 7 years ago
Revision 4f6ca971 | View on GitHub
Update viewset regex to allow period
Updated by werwty over 7 years ago
- Status changed from POST to MODIFIED
Applied in changeset pulp|4f6ca97154bebc1fa7caa448252ee43368804163.
Updated by bmbouter almost 5 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Updated by bmbouter over 4 years ago
- Category deleted (
14)
We are removing the 'API' category per open floor discussion June 16, 2020.
Actions
Update viewset regex to allow period
closes #2755 https://pulp.plan.io/issues/2755