Project

Profile

Help

Issue #805

closed

API call to import into a repo throws 500 when missing required params

Added by amacdona@redhat.com over 9 years ago. Updated over 5 years ago.

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

Description

If the call to this endpoint is missing any of the required body parameters, a server error occurs (KeyError)

To replicate

$ curl -s -H "Accept: application/json" -H "WebFrameworkSwitch: webpy" -X POST -d '' -k -u admin:admin "https://localhost/pulp/api/v2/repositories/test/actions/import_upload/" | python -mjson.tool

Actual Results

{
    "_href": "/pulp/api/v2/repositories/test/actions/import_upload/",
    "error_message": "'upload_id'",
    "exception": [
        "KeyError: 'upload_id'\n"
    ],
    "http_request_method": "POST",
    "http_status": 500,
    "traceback": [
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/middleware/exception.py\", line 46, in __call__\n    return self.app(environ, start_response)\n",
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/middleware/postponed.py\", line 55, 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/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 18, in _handle_with_processors\n    return process(self.processors)\n",
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 15, 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/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 15, in <lambda>\n    return p(lambda: process(processors))\n",
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 15, 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/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 15, in <lambda>\n    return p(lambda: process(processors))\n",
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 17, 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/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 18, in _handle_with_processors\n    return process(self.processors)\n",
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 15, 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/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 15, in <lambda>\n    return p(lambda: process(processors))\n",
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 15, 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/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 15, in <lambda>\n    return p(lambda: process(processors))\n",
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/application.py\", line 17, 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/austin/devel/pulp/server/pulp/server/webservices/controllers/decorators.py\", line 241, in _auth_decorator\n    return _verify_auth(self, operation, super_user_only, method, *args, **kwargs)\n",
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/controllers/decorators.py\", line 195, in _verify_auth\n    value = method(self, *args, **kwargs)\n",
        "  File \"/home/austin/devel/pulp/server/pulp/server/webservices/controllers/repositories.py\", line 860, in POST\n    upload_id = params['upload_id']\n"
    ]
}

Expected Results

400 error with details about missing params.

Note: this will be fixed in the django conversion

Added by Austin Macdonald over 9 years ago

Revision 089b0f0e | View on GitHub

django conversion - repositories

closes #707 closes #749 closes #756 closes #804 closes #805 closes #812

Added by Austin Macdonald over 9 years ago

Revision 089b0f0e | View on GitHub

django conversion - repositories

closes #707 closes #749 closes #756 closes #804 closes #805 closes #812

Actions #1

Updated by Anonymous over 9 years ago

  • Status changed from ASSIGNED to MODIFIED
  • % Done changed from 0 to 100
Actions #2

Updated by dkliban@redhat.com over 9 years ago

  • Status changed from MODIFIED to 5
Actions #3

Updated by pthomas@redhat.com over 9 years ago

  • Status changed from 5 to 6

Verified

[root@qe-blade-10 ~]# rpm -qa pulp-server
pulp-server-2.7.0-0.3.beta.el6.noarch
<\pre>
[root@qe-blade-10 ~]# 
[root@qe-blade-10 ~]# 
[root@qe-blade-10 ~]# 
[root@qe-blade-10 ~]# 
[root@qe-blade-10 ~]# curl -s -H "Accept: application/json" -H "WebFrameworkSwitch: webpy" -X POST -d '' -k -u admin:admin "https://localhost/pulp/api/v2/repositories/zoo/actions/import_upload/" | python -mjson.tool
{
    "_href": "/pulp/api/v2/repositories/zoo/actions/import_upload/", 
    "args": [], 
    "error": {
        "code": "PLP1009", 
        "data": {}, 
        "description": "The request body does not contain valid JSON", 
        "sub_errors": []
    }, 
    "error_message": "The request body does not contain valid JSON", 
    "exception": null, 
    "http_request_method": "POST", 
    "http_status": 400, 
    "traceback": null
}
[root@qe-blade-10 ~]# 
<\pre>
Actions #4

Updated by amacdona@redhat.com about 9 years ago

  • Status changed from 6 to CLOSED - CURRENTRELEASE
Actions #6

Updated by bmbouter over 5 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF