Changes between Initial Version and Version 2 of Ticket #34173
- Timestamp:
- Nov 22, 2022, 3:28:16 AM (23 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #34173
- Property Summary SessionMiddleware only returns 400 or 500 error in case of DB issues. → SessionMiddleware support 503 status code
- Property Type Bug → New feature
-
Ticket #34173 – Description
initial v2 3 3 I have the following situation. In one of my applications I'm having an issue with returning the right status code. 4 4 For example I had this situation where I wanted to list 1000 results, this normally takes a couple of seconds, but during this request, my DB went offline or got stuck for some reason. Currently, this resulted in a 500 status code. 5 As I have a custom controller that only retries tasks on specific status codes (like 503), I want to return a 503 status code (I also think that 503 is a more suitable one than 500 in this case), but this resulted in returning a 400 status code. The reason for that is the SessionMiddleware and particularly this part:5 In the API client that interfaces with this code we want to return a 503 because of an external source that only retries tasks on specific status codes (like 503), The current SessionMiddleware hijacks the statuscode and makes it impossible to raise a Service Unavailable (503). 6 6 7 7 {{{ … … 25 25 ) 26 26 }}} 27 As my DB is offline, this results in a 400 error, as the session can't be saved. 27 28 As my DB is offline, this results in a 400 error, as the session can't be saved. But this is incorrect, as the base request isn't a bad request. 28 29 I rewrote this small piece in a custom middleware that inherits the SessionMiddleware, but this is not a futureproof solution: 29 30 … … 51 52 It's a small change, but it will make it hard for us to keep track of all the Django updates. 52 53 53 Do you have a genericsolution for this issue?54 Do you have a solution for this issue? 54 55 55 56 Thanks in advance.