Open jakubsvehla opened 3 days ago
Please verify that this modified truth table matches the behavior in Flask.
The PROPAGATE_EXCEPTIONS
flag in Flask behaves differently in two ways:
None
is not treated as False
(as currently in Quart). When it’s None
, it takes the value of the testing
flag.PROPAGATE_EXCEPTIONS
flag has precedence over the testing
flag. So if PROPAGATE_EXCEPTIONS
is False and testing
True, then it won’t propagate exceptions (in Quart it would right now).So Flask’s truth table (when ignoring the debug
flag) is as follows:
PROPAGATE_EXCEPTIONS | testing | Raise (Flask) | Raise (Quart after the current fix) | |
---|---|---|---|---|
None | True | True | True | |
None | False | False | False | |
True | True | True | True | |
True | False | True | True | |
False | True | False | True | <- This line differs |
False | False | False | False |
The difference is that in Flask, setting PROPAGATE_EXCEPTIONS
to False
overrides the testing
flag.
So the question is whether we want to replicate Flask’s behavior or simply fix the bug. I think both behaviors make sense but the previous Quart’s behavior (before this fix) is in my opinion clearly wrong since it does not propagate exceptions when the PROPAGATE_EXCEPTIONS
is True which I think should be the expected behavior.
You can find the relevant code in Flask here: https://github.com/pallets/flask/blob/bc098406af9537aacc436cb2ea777fbc9ff4c5aa/src/flask/app.py#L841
As far as I know, there are no tests for the interaction of the two flags. They are tested independently here: https://github.com/pallets/flask/blob/bc098406af9537aacc436cb2ea777fbc9ff4c5aa/tests/test_basic.py#L1574
Fixes propagating exceptions when the
PROPAGATE_EXCEPTIONS
config setting is set toTrue
by fixing exception handling inASGIHTTPConnection
. Currently, whenPROPAGATE_EXCEPTIONS
is set toTrue
it returns the traceback as HTML instead of propagating the exception.