diff options
| author | Naveed Massjouni <naveedm9@gmail.com> | 2011-03-07 15:05:07 -0500 |
|---|---|---|
| committer | Naveed Massjouni <naveedm9@gmail.com> | 2011-03-07 15:05:07 -0500 |
| commit | bcb18ee3d0d095b616c0909c92a151a599d4e17f (patch) | |
| tree | 75ab9982347d42d1c0a74fec860152780df5f47a /nova/api | |
| parent | 2280848e8477c33f2a903eb7f821dcbcc90ce307 (diff) | |
Invalid values for offset and limit params in http requests now return a 400
response with a useful message in the body. Also added and updated tests.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/common.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 9f85c5c8a..f7a9cc3f0 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -36,15 +36,18 @@ def limited(items, request, max_limit=1000): try: offset = int(request.GET.get('offset', 0)) except ValueError: - offset = 0 + raise webob.exc.HTTPBadRequest(_('offset param must be an integer')) try: limit = int(request.GET.get('limit', max_limit)) except ValueError: - limit = max_limit + raise webob.exc.HTTPBadRequest(_('limit param must be an integer')) - if offset < 0 or limit < 0: - raise webob.exc.HTTPBadRequest() + if limit < 0: + raise webob.exc.HTTPBadRequest(_('limit param must be positive')) + + if offset < 0: + raise webob.exc.HTTPBadRequest(_('offset param must be positive')) limit = min(max_limit, limit or max_limit) range_end = offset + limit |
