Repository: fedora-infra/bodhi

Issue:
TypeError: __init__() takes exactly 3 arguments upon 400 request for unknown release
@nirik let me know about a traceback he saw in production today, which turns out to be easily reproducible in the dev environment as well. Simply visit http://localhost:6543/updates/?release=F20&type=security and you will see this in the logs:

```
2018-09-13 22:56:34,961 DEBUG [bodhi.server][waitress] route matched for url http://localhost:6543/updates/?release=F20&type=security; route_name: 'updates', path_info: u'/updates/', pat
2018-09-13 22:56:34,964 DEBUG [bodhi.server][waitress] debug_authorization of url http://localhost:6543/updates/?release=F20&type=security (view name u'' against context <bodhi.server.se
: Allowed (no permission registered)
/usr/lib/python2.7/site-packages/cornice/validators/_colander.py:62: DeprecationWarning: Setting schema to a class is deprecated.  Set schema to an instance instead.
  class_attrs[location] = _ensure_instantiated(schema)
2018-09-13 22:56:34,969 ERROR [bodhi.server][waitress] Error caught.  Handling HTML response.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pyramid/tweens.py", line 39, in excview_tween
    response = handler(request)
  File "/usr/lib/python2.7/site-packages/pyramid/router.py", line 156, in handle_request
    view_name
  File "/usr/lib/python2.7/site-packages/pyramid/view.py", line 642, in _call_view
    response = view_callable(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid/config/views.py", line 181, in __call__
    return view(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid/viewderivers.py", line 390, in attr_view
    return view(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid/viewderivers.py", line 368, in predicate_wrapper
    return view(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid/viewderivers.py", line 352, in authdebug_view
    return view(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid/viewderivers.py", line 439, in rendered_view
    result = view(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid/viewderivers.py", line 148, in _requestonly_view
    response = view(request)
  File "/usr/lib/python2.7/site-packages/cornice/service.py", line 507, in wrapper
    return args['error_handler'](request)
TypeError: __init__() takes exactly 3 arguments (2 given)
```


Discussion:

Resolving patch:
diff --git a/bodhi/server/services/errors.py b/bodhi/server/services/errors.py
--- a/bodhi/server/services/errors.py
+++ b/bodhi/server/services/errors.py
@@ -72,7 +72,7 @@ def status2summary(status):
 class html_handler(pyramid.httpexceptions.HTTPError):
     """An HTML formatting handler for all our errors."""
 
-    def __init__(self, errors, request):
+    def __init__(self, request):
         """
         Initialize the HTML error handler to render an error messgae for human readers.
 
@@ -80,7 +80,6 @@ def __init__(self, errors, request):
         status code to the code specified by errors.
 
         Args:
-            errors (cornice.errors.Errors): The errors to be rendered as HTML for users.
             request (pyramid.util.Request): The current Request.
         """
         location = config.get('mako.directories')
@@ -92,6 +91,7 @@ def __init__(self, errors, request):
             input_encoding='utf-8',
         )
         template = lookup.get_template('errors.html')
+        errors = request.errors
 
         try:
             body = template.render(
diff --git a/bodhi/server/views/generic.py b/bodhi/server/views/generic.py
--- a/bodhi/server/views/generic.py
+++ b/bodhi/server/views/generic.py
@@ -445,5 +445,6 @@ def exception_view(exc, request):
 
         errors = cornice.errors.Errors(status=status)
         errors.add('body', description=description)
+        request.errors = errors
 
-    return bodhi.server.services.errors.html_handler(errors, request)
+    return bodhi.server.services.errors.html_handler(request)


Test patch: