Project

Profile

Help

Issue #6521

closed

An internal server error is raised when creating a new content using repository_version instead of repository

Added by lmjachky about 4 years ago. Updated almost 4 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 71
Quarter:

Description

When I execute the following call, an internal server error is raised:

$ http --form POST :24817/pulp/api/v3/content/rpm/advisories/ file@./advisory.json repository=/pulp/api/v3/repositories/rpm/rpm/fc483a38-4fe5-4a61-afbe-76f1d8d73444/versions/1/ relative_path='advisory.json'

This call is however invalid because I am passing there repositoty_version instead of repository. Therefore, it should rather return an HTTP 400 response to prevent the server failures. I used there pulp_rpm as an example but I think other plugins are affected too, that is why it should be addressed globally in pulpcore. See the attached traceback:

Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]: pulp: django.request:ERROR: Internal Server Error: /pulp/api/v3/content/rpm/advisories/
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]: Traceback (most recent call last):
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     response = get_response(request)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     response = self.process_exception_by_middleware(e, request)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     return view_func(*args, **kwargs)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/viewsets.py", line 114, in view
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     return self.dispatch(request, *args, **kwargs)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/views.py", line 505, in dispatch
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     response = self.handle_exception(exc)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/views.py", line 465, in handle_exception
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     self.raise_uncaught_exception(exc)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     raise exc
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     response = handler(request, *args, **kwargs)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/home/vagrant/devel/pulpcore/pulpcore/plugin/viewsets/content.py", line 39, in create
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     serializer.is_valid(raise_exception=True)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/serializers.py", line 235, in is_valid
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     self._validated_data = self.run_validation(self.initial_data)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/serializers.py", line 430, in run_validation
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     value = self.to_internal_value(data)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/serializers.py", line 487, in to_internal_value
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     validated_value = field.run_validation(primitive_value)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/relations.py", line 153, in run_validation
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     return super().run_validation(data)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/fields.py", line 542, in run_validation
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     value = self.to_internal_value(data)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/relations.py", line 365, in to_internal_value
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     return self.get_object(match.view_name, match.args, match.kwargs)
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/home/vagrant/devel/pulpcore/pulpcore/app/serializers/base.py", line 211, in get_object
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     return super().get_object(*args, **kwargs).cast()
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:   File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rest_framework/relations.py", line 305, in get_object
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]:     lookup_value = view_kwargs[self.lookup_url_kwarg]
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]: KeyError: 'pk'
Apr 17 19:59:29 pulp3-source-fedora30.localhost.example.com gunicorn[19821]: 127.0.0.1 - admin [17/Apr/2020:19:59:29 +0000] "POST /pulp/api/v3/content/rpm/advisories/ HTTP/1.1" 500 27 "-" "HTTPie/2.0.0"

Also available in: Atom PDF