Project

Profile

Help

Issue #2755

Workers API endpoint unusable due to improperly configured lookup_field

Added by fdobrovo over 2 years ago. Updated 6 months ago.

Status:
MODIFIED
Priority:
High
Assignee:
Category:
API
Sprint/Milestone:
Start date:
Due date:
Severity:
3. High
Version:
Platform Release:
Blocks Release:
OS:
Backwards Incompatible:
No
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
QA Contact:
Complexity:
Smash Test:
Verified:
No
Verification Required:
No
Sprint:
Sprint 20

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.

Associated revisions

Revision 4f6ca971 View on GitHub
Added by werwty over 2 years ago

Update viewset regex to allow period

closes #2755
https://pulp.plan.io/issues/2755

Revision 4f6ca971 View on GitHub
Added by werwty over 2 years ago

Update viewset regex to allow period

closes #2755
https://pulp.plan.io/issues/2755

Revision 4f6ca971 View on GitHub
Added by werwty over 2 years ago

Update viewset regex to allow period

closes #2755
https://pulp.plan.io/issues/2755

History

#1 Updated by mhrivnak over 2 years ago

  • Sprint/Milestone set to 38
  • Triaged changed from No to Yes

#2 Updated by bizhang over 2 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.

#3 Updated by bizhang over 2 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

PR: https://github.com/pulp/pulp/pull/3027

#4 Updated by mhrivnak over 2 years ago

  • Sprint/Milestone changed from 38 to 39

#5 Updated by werwty over 2 years ago

  • Status changed from POST to MODIFIED

#6 Updated by bmbouter over 1 year ago

  • Sprint set to Sprint 20

#7 Updated by bmbouter over 1 year ago

  • Sprint/Milestone deleted (39)

#8 Updated by daviddavis 6 months ago

  • Sprint/Milestone set to 3.0

#9 Updated by bmbouter 6 months ago

  • Tags deleted (Pulp 3)

Please register to edit this issue

Also available in: Atom PDF