Project

Profile

Help

Issue #7468

closed

Internal error when adding (wrong) content advisory

Added by thm over 3 years ago. Updated over 3 years ago.

Status:
CLOSED - CURRENTRELEASE
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
Actions #1

Updated by fao89 over 3 years 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

Actions #2

Updated by ttereshc over 3 years ago

  • Sprint set to Sprint 81
Actions #3

Updated by ttereshc over 3 years ago

  • Triaged changed from No to Yes
Actions #4

Updated by ipanova@redhat.com over 3 years ago

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

Updated by pulpbot over 3 years ago

  • Status changed from ASSIGNED to POST
Actions #6

Updated by rchan over 3 years ago

  • Sprint changed from Sprint 81 to Sprint 82

Added by ipanova@redhat.com over 3 years ago

Revision 6b78e365 | View on GitHub

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

[nocoverage]

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

Actions #7

Updated by ipanova@redhat.com over 3 years ago

  • Status changed from POST to MODIFIED
Actions #8

Updated by dalley over 3 years ago

  • Sprint/Milestone set to 3.8.0
Actions #9

Updated by pulpbot over 3 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF