Project

Profile

Help

Issue #1356

Pulp returns HTTP 500 when a bad request is made during repo creation.

Added by jcline@redhat.com about 5 years ago. Updated almost 2 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Master
Platform Release:
2.8.0
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Easy Fix, Pulp 2
Sprint:
Quarter:

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

Copied to Pulp - Issue #1745: Pulp returns HTTP 500 when a bad request is made during sync schedule creationCLOSED - DUPLICATE<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>

Associated revisions

Revision 75af2dd1 View on GitHub
Added by ttereshc about 5 years ago

1356 - Pulp returns HTTP 500 when a bad request is made during repo creation.

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

Revision 75af2dd1 View on GitHub
Added by ttereshc about 5 years ago

1356 - Pulp returns HTTP 500 when a bad request is made during repo creation.

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

History

#1 Updated by jcline@redhat.com about 5 years ago

  • Version set to Master

#2 Updated by amacdona@redhat.com about 5 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')

#3 Updated by mhrivnak about 5 years ago

  • Triaged changed from No to Yes

This is likely an issue on many API endpoints.

#4 Updated by mhrivnak about 5 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to ttereshc

#5 Updated by ttereshc about 5 years ago

  • Status changed from ASSIGNED to POST
  • Platform Release set to 2.8.0

#6 Updated by ttereshc about 5 years ago

  • Status changed from POST to MODIFIED
  • % Done changed from 0 to 100

#7 Updated by Ichimonji10 about 5 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.

#8 Updated by ttereshc about 5 years ago

Against which version of Pulp are you running tests? I am not able to reproduce this issue on a master.

#9 Updated by Ichimonji10 almost 5 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.

#10 Updated by dkliban@redhat.com almost 5 years ago

  • Status changed from MODIFIED to 5

#11 Updated by Ichimonji10 almost 5 years ago

  • Copied to Issue #1745: Pulp returns HTTP 500 when a bad request is made during sync schedule creation added

#12 Updated by dkliban@redhat.com almost 5 years ago

  • Status changed from 5 to CLOSED - CURRENTRELEASE

#13 Updated by bmbouter almost 2 years ago

  • Tags Pulp 2 added

Please register to edit this issue

Also available in: Atom PDF