Project

Profile

Help

Issue #2755

closed

Workers API endpoint unusable due to improperly configured lookup_field

Added by fdobrovo over 7 years ago. Updated over 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
High
Assignee:
Category:
-
Sprint/Milestone:
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.
Actions #1

Updated by mhrivnak over 7 years ago

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

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.

Actions #3

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

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

Actions #4

Updated by mhrivnak over 7 years ago

  • Sprint/Milestone changed from 38 to 39

Added by werwty over 7 years ago

Revision 4f6ca971 | View on GitHub

Update viewset regex to allow period

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

Added by werwty over 7 years ago

Revision 4f6ca971 | View on GitHub

Update viewset regex to allow period

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

Actions #5

Updated by werwty over 7 years ago

  • Status changed from POST to MODIFIED
Actions #6

Updated by bmbouter almost 7 years ago

  • Sprint set to Sprint 20
Actions #7

Updated by bmbouter almost 7 years ago

  • Sprint/Milestone deleted (39)
Actions #8

Updated by daviddavis over 5 years ago

  • Sprint/Milestone set to 3.0.0
Actions #9

Updated by bmbouter over 5 years ago

  • Tags deleted (Pulp 3)
Actions #10

Updated by bmbouter about 5 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Actions #11

Updated by bmbouter over 4 years ago

  • Category deleted (14)

We are removing the 'API' category per open floor discussion June 16, 2020.

Also available in: Atom PDF