Repository navigation
Closed
Labels
Description
Version
pulpcore 3.22 (and probably most versions below)
Describe the bug
When parsing the content units for the add and remove fields for the modify endpoint, invalid inputs can cause a 500 error.
To Reproduce
# Using the pulp_file pytest fixtures
def test_bad_inputs(file_repo_api_client, file_random_content_unit):
repo = file_repo_api_client.create(name="testing")
body = {"add_content_units": file_random_content_unit} # Valid form is file_random_conent_unit.pulp_href
file_repo_api_client.modify(repo.pulp_href, body)Expected behavior
The server should return a 400 stating the input for the add or remove field is invalid.
Additional context
Stack trace
pulp_1 | pulp [4c43a9c4-1225-4efc-94b7-3fb7093f5db5]: django.request:ERROR: Internal Server Error: /pulp/api/v3/repositories/file/file/c2fad42e-a21e-47b8-9f56-16514d850526/modify/
pulp_1 | Traceback (most recent call last):
pulp_1 | File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
pulp_1 | response = get_response(request)
pulp_1 | File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
pulp_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
pulp_1 | File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
pulp_1 | return view_func(*args, **kwargs)
pulp_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view
pulp_1 | return self.dispatch(request, *args, **kwargs)
pulp_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
pulp_1 | response = self.handle_exception(exc)
pulp_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
pulp_1 | self.raise_uncaught_exception(exc)
pulp_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
pulp_1 | raise exc
pulp_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
pulp_1 | response = handler(request, *args, **kwargs)
pulp_1 | File "/src/pulpcore/pulpcore/plugin/actions.py", line 46, in modify
pulp_1 | add_content_units[NamedModelViewSet.extract_pk(url)] = url
pulp_1 | File "/src/pulpcore/pulpcore/app/viewsets/base.py", line 219, in extract_pk
pulp_1 | match = resolve(urlparse(uri).path)
pulp_1 | File "/usr/lib64/python3.8/urllib/parse.py", line 376, in urlparse
pulp_1 | url, scheme, _coerce_result = _coerce_args(url, scheme)
pulp_1 | File "/usr/lib64/python3.8/urllib/parse.py", line 128, in _coerce_args
pulp_1 | return _decode_args(args) + (_encode_result,)
pulp_1 | File "/usr/lib64/python3.8/urllib/parse.py", line 112, in _decode_args
pulp_1 | return tuple(x.decode(encoding, errors) if x else '' for x in args)
pulp_1 | File "/usr/lib64/python3.8/urllib/parse.py", line 112, in <genexpr>
pulp_1 | return tuple(x.decode(encoding, errors) if x else '' for x in args)
pulp_1 | AttributeError: 'dict' object has no attribute 'decode'
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
gerrod3 commentedon Jan 25, 2023
Related to #3486
lubosmj commentedon Feb 1, 2023
Yes, the issues are related. I am attaching the snippet from the duplicate issue.
Add a child validator to the /repository/modify serializer
Add a child validator to the /repository/modify serializer
Add a child validator to the /repository/modify serializer
Add a child validator to the /repository/modify serializer
Add a child validator to the /repository/modify serializer
Add a child validator to the /repository/modify serializer
Add a child validator to the /repository/modify serializer
Add a child validator to the /repository/modify serializer
Add a child validator to the /repository/modify serializer
Add a child validator to the /repository/modify serializer