#19648: Middleware process_exception not called when another middleware raises
an
error
----------------------------------------+------------------------
Reporter: akaariai | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
It seems that process_exception isn't called at all if anther middleware
below it raises an exception in process_request. This has some interesting
side-effects. For example, if you have this setting:
{{{
MIDDLEWARE_CLASSES = [
'TransactionMiddleware',
'SavesToDB',
'RaisesException'
]
}}}
The end result is that first, transaction middleware will open a
transaction, second SavesToDB will save to DB, finally RaisesException
raises an exception. Now, process_exception isn't called, we go directly
to process_response stage. assume that RaisesException and SavesToDB do
nothing. So, finally transaction middleware commits the transaction. Which
seems like exactly the wrong thing to do. My interpretation is that if an
exception happens below transaction middleware, then the transaction will
be rolled back, no matter if the source is the view or another middleware.
IMO we should do a process_exception() dance in case another middleware
raises an exception. Probably we should go just through those middleware
classes before the exception.
Another option is do immediate 500 response and not proceed to do anything
else if process_request raises an exception. Middleware's process_request
should not throw an error, so this would be "critical error, bail out
immediately" response to erroneous middleware.
--
Ticket URL: <https://code.djangoproject.com/ticket/19648>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.