Project

Profile

Help

Issue #7468

Internal error when adding (wrong) content advisory

Added by thm about 2 months ago. Updated 28 days ago.

Status:
MODIFIED
Priority:
Normal
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 82
Quarter:

Description

Accidentally sent an RPM as file to ContentAdvisoriesApi().create(), yielding an Server Error (500). It probably should throw a ValidationError instead.

Here's the stacktrace

api_1               | pulp: django.request:ERROR: Internal Server Error: /pulp/api/v3/content/rpm/advisories/
api_1               | Traceback (most recent call last):
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
api_1               |     response = get_response(request)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
api_1               |     response = self.process_exception_by_middleware(e, request)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
api_1               |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
api_1               |     return view_func(*args, **kwargs)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/rest_framework/viewsets.py", line 114, in view
api_1               |     return self.dispatch(request, *args, **kwargs)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/rest_framework/views.py", line 505, in dispatch
api_1               |     response = self.handle_exception(exc)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/rest_framework/views.py", line 465, in handle_exception
api_1               |     self.raise_uncaught_exception(exc)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
api_1               |     raise exc
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/rest_framework/views.py", line 502, in dispatch
api_1               |     response = handler(request, *args, **kwargs)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/pulpcore/plugin/viewsets/content.py", line 47, in create
api_1               |     serializer.is_valid(raise_exception=True)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/rest_framework/serializers.py", line 235, in is_valid
api_1               |     self._validated_data = self.run_validation(self.initial_data)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/rest_framework/serializers.py", line 433, in run_validation
api_1               |     value = self.validate(value)
api_1               |   File "/opt/pulp/lib/python3.8/site-packages/pulp_rpm/app/serializers/advisory.py", line 204, in validate
api_1               |     update_record_data.update(json.loads(data["file"].read()))
api_1               |   File "/usr/lib64/python3.8/json/__init__.py", line 343, in loads
api_1               |     s = s.decode(detect_encoding(s), 'surrogatepass')
api_1               | UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 0: invalid continuation byte

Associated revisions

Revision 6b78e365 View on GitHub
Added by ipanova@redhat.com 28 days ago

Raise ValidationError when other type than json is provided during Advisory upload.

[nocoverage]

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

History

#1 Updated by fao89 about 1 month ago

We need to improve UpdateRecordSerializer validation

api_1               |   File "/opt/pulp/lib/python3.8/site-packages/pulp_rpm/app/serializers/advisory.py", line 204, in validate
api_1               |     update_record_data.update(json.loads(data["file"].read()))

it is breaking because it is trying to convert an RPM into JSON

#2 Updated by ttereshc about 1 month ago

  • Sprint set to Sprint 81

#3 Updated by ttereshc about 1 month ago

  • Triaged changed from No to Yes

#4 Updated by ipanova@redhat.com about 1 month ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to ipanova@redhat.com

#5 Updated by pulpbot about 1 month ago

  • Status changed from ASSIGNED to POST

#6 Updated by rchan about 1 month ago

  • Sprint changed from Sprint 81 to Sprint 82

#7 Updated by ipanova@redhat.com 28 days ago

  • Status changed from POST to MODIFIED

Please register to edit this issue

Also available in: Atom PDF