Fix error e-mails sent to admins in response to expected HTTP 500 codes.
Review Request #12417 — Created June 27, 2022 and submitted
We hit a regression when deploying Review Board 5 to production. API
responses that returned a HTTP 500 (which we use to indicate an issue
usually with a service Review Board is talking to) were resulting in
e-mails sent to the administrations indicating a problem. These were
The problem has to do with a behavioral change in Django, which is less
than ideal. In older versions, uncaught exceptions would result in an
error log message, which in turn triggered a handler to send an e-mail.
HttpResponseinstance was instead returned, it would be returned
With the modern behavior, any
HttpResponsewith a HTTP 500+ would
trigger this e-mail behavior.
Fortunately, as part of the logging message, there's an exception
traceback in the uncaught exception case, but not in the standard
response case. We can use this to disable this behavior.
This requires setting an explicit
The settings are documented as being based on Django 3.2's settings,
with our specific changes listed.
In all tests conducted, this brings us back to the behavior we've been
used to with prior versions of Django.
Accessed APIs (e.g.,
/api/repository/1/info/) that returned HTTP 500+
responses. Didn't see a logged e-mail, but did see the logged HTTP line,
Triggered an exception in a view. Saw a logged e-mail, as expected.
require_exceptions -> require_exception