Project

Profile

Help

Issue #482

Malformed JSON results in a 500 response

Added by jcline@redhat.com over 4 years ago. Updated 5 months ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
API
Sprint/Milestone:
-
Start date:
Due date:
Severity:
1. Low
Version:
Master
Platform Release:
2.7.0
Blocks Release:
OS:
Backwards Incompatible:
No
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Complexity:
Smash Test:
Verified:
Yes
Verification Required:
No
Sprint:

Description

Description of problem:
If you pass unparsable JSON to Pulp, it results in a 500.

Version-Release number of selected component (if applicable): master

How reproducible:

Steps to Reproduce:
1. curl -i -H "Accept: application/json" -X POST -d '{"oh_no": "I_forgot_a_closing_mustachio"' -u admin:admin -k 'https://localhost/pulp/api/v2/repositories/'
2.
3.

Actual results:
HTTP/1.1 500 Internal Server Error
Date: Thu, 07 Aug 2014 15:35:05 GMT
Server: Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.5 Python/2.7.5
Content-Encoding: utf-8
Content-Length: 4686
Connection: close
Content-Type: application/json

{
"_href": "/pulp/api/v2/repositories/",
"error_message": "Unhandled Exception",
"exception": [
"ValueError: Expecting object: line 1 column 40 (char 39)\n"
],
"http_request_method": "POST",
"http_status": 500,
"traceback": [
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/middleware/exception.py\", line 44, in call\n return self.app(environ, start_response)\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/middleware/postponed.py\", line 42, in call\n return self.app(environ, start_response)\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 279, in wsgi\n result = self.handle_with_processors()\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 29, in handle_with_processors\n return process(self.processors)\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 26, in process\n return p(lambda: process(processors))\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 566, in processor\n return handler()\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 26, in <lambda>\n return p(lambda: process(processors))\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 26, in process\n return p(lambda: process(processors))\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 581, in processor\n result = handler()\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 26, in <lambda>\n return p(lambda: process(processors))\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 28, in process\n return self.handle()\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 230, in handle\n return self._delegate(fn, self.fvars, args)\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 422, in _delegate\n return f()\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 430, in <lambda>\n f = lambda: self._delegate_sub_application(pat, what)\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 455, in _delegate_sub_application\n return app.handle_with_processors()\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 29, in _handle_with_processors\n return process(self.processors)\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 26, in process\n return p(lambda: process(processors))\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 566, in processor\n return handler()\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 26, in <lambda>\n return p(lambda: process(processors))\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 26, in process\n return p(lambda: process(processors))\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 581, in processor\n result = handler()\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 26, in <lambda>\n return p(lambda: process(processors))\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/application.py\", line 28, in process\n return self.handle()\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 230, in handle\n return self._delegate(fn, self.fvars, args)\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 420, in _delegate\n return handle_class(cls)\n",
" File \"/usr/lib/python2.7/site-packages/web/application.py\", line 396, in handle_class\n return tocall(*args)\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/controllers/decorators.py\", line 227, in _auth_decorator\n value = method(self, *args, **kwargs)\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/controllers/repositories.py\", line 149, in POST\n repo_data = self.params()\n",
" File \"/home/jcline/devel/pulp/server/pulp/server/webservices/controllers/base.py\", line 67, in params\n deserialized_data = json.loads(data)\n",
" File \"/usr/lib64/python2.7/json/
_init__.py\", line 338, in loads\n return _default_decoder.decode(s)\n",
" File \"/usr/lib64/python2.7/json/decoder.py\", line 365, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n",
" File \"/usr/lib64/python2.7/json/decoder.py\", line 381, in raw_decode\n obj, end = self.scan_once(s, idx)\n"
]
}

Expected results:
Something a little more graceful

Additional info:

+ This bug was cloned from Bugzilla Bug #1127821 +

History

#1 Updated by amacdona@redhat.com over 4 years ago

This change will be made for all urls through the django conversion.

#2 Updated by bmbouter over 4 years ago

  • Severity changed from Low to 1. Low

#3 Updated by amacdona@redhat.com over 4 years ago

  • Status changed from ASSIGNED to MODIFIED
  • Platform Release set to 2.7.0

#4 Updated by dkliban@redhat.com over 4 years ago

  • Status changed from MODIFIED to ON_QA

#5 Updated by pthomas@redhat.com about 4 years ago

  • Status changed from ON_QA to VERIFIED
  • QA Contact set to pthomas@redhat.com

Verified

[root@qe-blade-10 ~]# rpm -qa pulp-server
pulp-server-2.7.0-0.3.beta.el6.noarch
[root@qe-blade-10 ~]# 


[root@qe-blade-10 ~]# curl -i -H "Accept: application/json" -X POST -d '{"oh_no": "I_forgot_a_closing_mustachio"' -u admin:admin -k 'https://localhost/pulp/api/v2/repositories/'
HTTP/1.1 400 BAD REQUEST
Date: Thu, 02 Jul 2015 14:29:58 GMT
Server: Apache/2.2.15 (Red Hat)
Content-Encoding: utf-8
Content-Length: 328
Connection: close
Content-Type: application/json

{"http_request_method": "POST", "exception": null, "error_message": "The request body does not contain valid JSON", "_href": "/pulp/api/v2/repositories/", "http_status": 400, "error": {"code": "PLP1009", "data": {}, "description": "The request body does not contain valid JSON", "sub_errors": []}, "args": [], "traceback": null}[root@qe-blade-10 ~]# 

#6 Updated by amacdona@redhat.com almost 4 years ago

  • Status changed from VERIFIED to CLOSED - CURRENTRELEASE

#7 Updated by pulpbot over 2 years ago

  • Verified changed from No to Yes

#8 Updated by bmbouter 5 months ago

  • Tags Pulp 2 added

Please register to edit this issue

Also available in: Atom PDF