Actions
Bug #62261
openmgr/dashboard: 500 internal error instead of 400 on invalid REST API parameters
% Done:
0%
Source:
Tags:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):
Description
Description of problem¶
If a REST API request has invalid parameters (at least for rgw for example /api/rgw/bucket
) then a 500 internal error is returned instead of a more suitable error such as 400 bad request.
Currently on Quincy wrong feedback is given to REST API users on an invalid request that was made.
Environment¶
ceph version
string: ceph version 17.2.6 (d7ff0d10654d2280e08f1ab989c7cdf3064446a5) quincy (stable)- Platform (OS/distro/release): EL9
- Cluster details (nodes, monitors, OSDs):
- Did it happen on a stable environment or after a migration/upgrade?: no
- Browser used (e.g.:
Version 86.0.4240.198 (Official Build) (64-bit)
):
How reproducible¶
Every time.
Steps:
- Make a request that is invalid; for example for
/api/rgw/bucket
pass an empty value instead of truthy value; example"lock_enabled": ""
- The server logs an error and returns 500 internal server error instead of a proper error value such as 400 bad request.
Actual results¶
Internal Server Error Traceback (most recent call last): File "/usr/share/ceph/mgr/dashboard/services/exception.py", line 47, in dashboard_exception_handler return handler(*args, **kwargs) File "/lib/python3.6/site-packages/cherrypy/_cpdispatch.py", line 54, in __call__ return self.callable(*self.args, **self.kwargs) File "/usr/share/ceph/mgr/dashboard/controllers/_base_controller.py", line 258, in inner ret = func(*args, **kwargs) File "/usr/share/ceph/mgr/dashboard/controllers/_rest_controller.py", line 191, in wrapper return func(*vpath, **params) File "/usr/share/ceph/mgr/dashboard/controllers/rgw.py", line 298, in create lock_enabled = str_to_bool(lock_enabled) File "/usr/share/ceph/mgr/dashboard/tools.py", line 748, in str_to_bool return bool(strtobool(val)) File "/lib64/python3.6/distutils/util.py", line 317, in strtobool raise ValueError("invalid truth value %r" % (val,)) ValueError: invalid truth value '' [::ffff:192.0.2.1:55555] [POST] [500] [0.003s] [user] [513.0B] /api/rgw/bucket [b'{"status": "500 Internal Server Error", "detail": "The server encountered an unexpected condition which prevented it from fulfilling the request.", [...]
Expected results¶
REST API should return a correct error that signals to REST API user that the request was invalid for example 400.
Additional info¶
Updated by Pedro González Gómez 8 months ago
- Status changed from New to Triaged
- Assignee set to Pedro González Gómez
Actions