Open achimwilde opened 4 years ago
This seems something to raise in the Zope issue tracker: https://github.com/zopefoundation/Zope/issues
Just checked, on Zope master, the above code is still there: https://github.com/zopefoundation/Zope/blob/master/src/ZPublisher/HTTPResponse.py#L61-L62
BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)
In Zope-4.1.1-py3.7.egg/ZPublisher/HTTPResponse.py:
status_codes['nameerror'] = 503 status_codes['keyerror'] = 503
With these lines, all NameError and KeyError exceptions are mapped to HTTP error code 503 ("Service Unavailable"), which is supposed to be used for temporary problems like having too much traffic. NameErrors happen when you access a variable that was not declared and KeyErrors are raised when you access a dictionary key that doesn't exist. Those are errors that usually persist so they should definately not generally be transformed into a HTTP 503 error.
We suspect that things were built that way because sometimes NameErrors and/or KeyErrors might get raised when there is a temporary problem, like some file system mountpoints don't yet exist when starting the server. For most users this appears to be sufficient, since the bug is in there for a very long time. But we need to correctly distinguish between error 500 and 503 in our load balancing: 503 errors cause the request to be retried with a different client (until there are no clients left). 500 errors have to be addressed by developers.
Our suggestion: It should be evaluated in which cases there really should be a 503 error when NameErrors oder KeyErrors get raised and those exceptions should be changed to more fitting, more specific exceptions which get mapped to HTTP status 503. Then the too generic 503 mapping for NameError and KeyError can be removed from HTTPResponse.py.
What I did:
Have fresh installed Plone, insert "raise NameError" or "raise KeyError" into generic view, restart Plone client and call view.
What I expect to happen:
Get HTTP response code 500.
What actually happened:
Got HTTP response code 503.
What version of Plone/ Addons I am using:
We checked Plone 5.2.1 and also some older Plone 4 and 5 versions. We suppose the issue applies to all current versions.