Uploaded image for project: 'Project Quay'
  1. Project Quay
  2. PROJQUAY-3419

Quota API should validate input before processing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Normal Normal
    • None
    • quay-v3.7.0
    • quay

      The quota api will accept 0 as a valid quota and attempt to divide by it, prompting a 500 loop in the UI.

      ```
      gunicorn-web stdout | 2022-03-16 16:48:08,342 [233] [ERROR] [gunicorn.error] Error handling request /api/v1/repository?last_modified=true&namespace=demo&popularity=true&public=false&quota=true&state=true
      gunicorn-web stdout | Traceback (most recent call last):
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 55, in handle
      gunicorn-web stdout | self.handle_request(listener_name, req, client, addr)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/gunicorn/workers/ggevent.py", line 127, in handle_request
      gunicorn-web stdout | super().handle_request(listener_name, req, sock, addr)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request
      gunicorn-web stdout | respiter = self.wsgi(environ, resp.start_response)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/app.py", line 2463, in _call_
      gunicorn-web stdout | return self.wsgi_app(environ, start_response)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/werkzeug/middleware/proxy_fix.py", line 232, in _call_
      gunicorn-web stdout | return self.app(environ, start_response)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/app.py", line 2449, in wsgi_app
      gunicorn-web stdout | response = self.handle_exception(e)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask_restful/_init_.py", line 269, in error_router
      gunicorn-web stdout | return original_handler(e)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/app.py", line 1866, in handle_exception
      gunicorn-web stdout | reraise(exc_type, exc_value, tb)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/_compat.py", line 38, in reraise
      gunicorn-web stdout | raise value.with_traceback(tb)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
      gunicorn-web stdout | response = self.full_dispatch_request()
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
      gunicorn-web stdout | rv = self.handle_user_exception(e)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask_restful/_init_.py", line 269, in error_router
      gunicorn-web stdout | return original_handler(e)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception
      gunicorn-web stdout | reraise(exc_type, exc_value, tb)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/_compat.py", line 38, in reraise
      gunicorn-web stdout | raise value.with_traceback(tb)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
      gunicorn-web stdout | rv = self.dispatch_request()
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
      gunicorn-web stdout | return self.view_functions[rule.endpoint](**req.view_args)
      gunicorn-web stdout | File "/quay-registry/endpoints/decorators.py", line 212, in wrapper
      gunicorn-web stdout | return func(*args, **kwargs)
      gunicorn-web stdout | File "/quay-registry/auth/decorators.py", line 65, in wrapper
      gunicorn-web stdout | return func(*args, **kwargs)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask_restful/utils/cors.py", line 35, in wrapped_function
      gunicorn-web stdout | resp = make_response(f(*args, **kwargs))
      gunicorn-web stdout | File "/quay-registry/endpoints/csrf.py", line 73, in wrapper
      gunicorn-web stdout | resp = func(*args, **kwargs)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask_restful/_init_.py", line 458, in wrapper
      gunicorn-web stdout | resp = resource(*args, **kwargs)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask/views.py", line 89, in view
      gunicorn-web stdout | return self.dispatch_request(*args, **kwargs)
      gunicorn-web stdout | File "/app/lib/python3.8/site-packages/flask_restful/_init_.py", line 573, in dispatch_request
      gunicorn-web stdout | resp = meth(*args, **kwargs)
      gunicorn-web stdout | File "/quay-registry/endpoints/decorators.py", line 141, in wrapper
      gunicorn-web stdout | return func(*args, **kwargs)
      gunicorn-web stdout | File "/quay-registry/endpoints/decorators.py", line 120, in wrapper
      gunicorn-web stdout | return func(*args, **kwargs)
      gunicorn-web stdout | File "/quay-registry/endpoints/api/_init_.py", line 382, in wrapped
      gunicorn-web stdout | return func(*args, **kwargs)
      gunicorn-web stdout | File "/quay-registry/endpoints/api/_init_.py", line 228, in wrapper
      gunicorn-web stdout | return func(self, *args, **kwargs)
      gunicorn-web stdout | File "/quay-registry/endpoints/api/_init_.py", line 205, in wrapper
      gunicorn-web stdout | (result, next_page_token) = func(self, *args, **kwargs)
      gunicorn-web stdout | File "/quay-registry/endpoints/api/repository.py", line 246, in get
      gunicorn-web stdout | repos, next_page_token = model.get_repo_list(
      gunicorn-web stdout | File "/quay-registry/endpoints/api/repository_models_pre_oci.py", line 156, in get_repo_list
      gunicorn-web stdout | quota_map[repo_id] = model.namespacequota.get_repo_quota_for_view(
      gunicorn-web stdout | File "/quay-registry/data/model/namespacequota.py", line 396, in get_repo_quota_for_view
      gunicorn-web stdout | percent_consumed = str(round((repo_quota / namespace_quota.limit_bytes) * 100, 2))
      gunicorn-web stdout | ZeroDivisionError: division by zero
      ```

              sdadi@redhat.com Sunanda Dadi (Inactive)
              doconnor@redhat.com Dave O'Connor
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: