Changes between Initial Version and Version 2 of Ticket #34173


Ignore:
Timestamp:
Nov 22, 2022, 3:28:16 AM (18 months ago)
Author:
SessionIssue
Comment:

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 BugNew feature
  • Ticket #34173 – Description

    initial v2  
    33I have the following situation. In one of my applications I'm having an issue with returning the right status code.
    44For 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:
     5In 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).
    66
    77{{{
     
    2525                    )
    2626}}}
    27 As my DB is offline, this results in a 400 error, as the session can't be saved.
     27
     28As 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.
    2829I rewrote this small piece in a custom middleware that inherits the SessionMiddleware, but this is not a futureproof solution:
    2930
     
    5152It's a small change, but it will make it hard for us to keep track of all the Django updates.
    5253
    53 Do you have a generic solution for this issue?
     54Do you have a solution for this issue?
    5455
    5556Thanks in advance.
Back to Top