Issue #1356
closedPulp returns HTTP 500 when a bad request is made during repo creation.
Description
If an incorrect JSON data type is provided when creating a repository (say an array rather than an object), Pulp returns an HTTP 500 rather than HTTP 400. This is demonstrated by the following pulp-smash test case: https://github.com/PulpQE/pulp-smash/pull/28/files#diff-df63d36099c3c8fe4fe877283d5eb7d1R96
Test failure:
======================================================================
FAIL: test_status_code (tests.platform.api_v2.test_repository.CreateFailureTestCase) [(400, [u'Incorrect data type'])]
Assert that each response has the expected HTTP status code.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/vagrant/devel/pulp-smash/pulp_smash/tests/platform/api_v2/test_repository.py", line 117, in test_status_code
self.assertEqual(response.status_code, self.bodies[i][0])
AssertionError: 500 != 400
======================================================================
Traceback:
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: Unhandled Exception
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) 'list' object has no attribute 'get'
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) Traceback (most recent call last):
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) response = wrapped_callback(request, *callback_args, **callback_kwargs)
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) File "/usr/lib/python2.7/site-packages/django/views/generic/base.py", line 71, in view
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) return self.dispatch(request, *args, **kwargs)
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) File "/usr/lib/python2.7/site-packages/django/views/generic/base.py", line 89, in dispatch
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) return handler(request, *args, **kwargs)
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) File "/home/vagrant/devel/pulp/server/pulp/server/webservices/views/decorators.py", line 239, in _auth_decorator
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) return _verify_auth(self, operation, super_user_only, method, *args, **kwargs)
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) File "/home/vagrant/devel/pulp/server/pulp/server/webservices/views/decorators.py", line 193, in _verify_auth
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) value = method(self, *args, **kwargs)
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) File "/home/vagrant/devel/pulp/server/pulp/server/webservices/views/util.py", line 111, in wrapper
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) return func(*args, **kwargs)
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) File "/home/vagrant/devel/pulp/server/pulp/server/webservices/views/repositories.py", line 137, in post
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) repo_id = repo_data.get('id')
Nov 05 09:48:13 dev pulp[4808]: pulp.server.webservices.middleware.exception:ERROR: (4808-32512) AttributeError: 'list' object has no attribute 'get'
Related issues
Updated by amacdona@redhat.com over 8 years ago
- Tags Easy Fix added
https://github.com/pulp/pulp/blob/master/server/pulp/server/webservices/views/repositories.py#L134
This just needs something like:
try:
repo_id = repo_data['id']
except KeyError:
raise exceptions.MissingValue('id')
except TypeError:
raise exceptions.InvalidValue('id')
Updated by mhrivnak over 8 years ago
- Triaged changed from No to Yes
This is likely an issue on many API endpoints.
Updated by mhrivnak about 8 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to ttereshc
Updated by ttereshc about 8 years ago
- Status changed from ASSIGNED to POST
- Platform Release set to 2.8.0
Added by ttereshc about 8 years ago
Added by ttereshc about 8 years ago
Revision 75af2dd1 | View on GitHub
1356 - Pulp returns HTTP 500 when a bad request is made during repo creation.
Updated by ttereshc about 8 years ago
- Status changed from POST to MODIFIED
- % Done changed from 0 to 100
Applied in changeset pulp|75af2dd1113d47a282911c6a88b47a7f7d193dde.
Updated by Ichimonji10 about 8 years ago
- Status changed from MODIFIED to ASSIGNED
The relevant Pulp Smash tests are failing in Jenkins. The failing tests are test_status_code
and test_body_status_code
from pulp_smash.tests.platform.api_v2.test_repository.CreateFailureTestCase. The most recent test run was 11 hours ago.
Updated by ttereshc about 8 years ago
Against which version of Pulp are you running tests? I am not able to reproduce this issue on a master.
Updated by Ichimonji10 about 8 years ago
- Status changed from ASSIGNED to MODIFIED
Against which version of Pulp are you running tests? I am not able to reproduce this issue on a master.
I'm testing against the current master version of Pulp. I'm using both Jenkins and local VMs to verify test results, and this bug was present in both when I last tested it five days ago.
I've re-run the relevant tests, and they now succeed for the master version of Pulp. This issue still affects Pulp 2.7, though I don't really expect a fix for a low-priority issue like this. I don't know why there was a delay before the fix started working. I'll put this issue back in MODIFIED state.
Updated by dkliban@redhat.com about 8 years ago
- Status changed from MODIFIED to 5
Updated by Ichimonji10 about 8 years ago
- Copied to Issue #1745: Pulp returns HTTP 500 when a bad request is made during sync schedule creation added
Updated by dkliban@redhat.com almost 8 years ago
- Status changed from 5 to CLOSED - CURRENTRELEASE
1356 - Pulp returns HTTP 500 when a bad request is made during repo creation.
closes #1356 https://pulp.plan.io/issues/1356