Re: [Django] #34173: SessionMiddleware support 503 status code

2022-11-24 Thread Django
#34173: SessionMiddleware support 503 status code
-+-
 Reporter:  SessionIssue |Owner:  Abhinav
 Type:   |  Yadav
  Cleanup/optimization   |   Status:  closed
Component:  contrib.sessions |  Version:  4.1
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"17472c3304050fbbf7a65976ab7b392184d081d1" 17472c3]:
 {{{
 #!CommitTicketReference repository=""
 revision="17472c3304050fbbf7a65976ab7b392184d081d1"
 Fixed #34173 -- Skipped saving sessions on 5xx responses.
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184aa1b6a50-774aebe5-019f-40ca-9d8c-e4822614222d-00%40eu-central-1.amazonses.com.


Re: [Django] #34173: SessionMiddleware support 503 status code

2022-11-24 Thread Django
#34173: SessionMiddleware support 503 status code
-+-
 Reporter:  SessionIssue |Owner:  Abhinav
 Type:   |  Yadav
  Cleanup/optimization   |   Status:  assigned
Component:  contrib.sessions |  Version:  4.1
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184a9e57297-05522322-41d6-4e46-96d5-21b987035933-00%40eu-central-1.amazonses.com.


Re: [Django] #34173: SessionMiddleware support 503 status code

2022-11-24 Thread Django
#34173: SessionMiddleware support 503 status code
-+-
 Reporter:  SessionIssue |Owner:  Abhinav
 Type:   |  Yadav
  Cleanup/optimization   |   Status:  assigned
Component:  contrib.sessions |  Version:  4.1
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Abhinav Yadav):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/16326 PR]

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184a98c4b80-4083cdd7-7a7c-4125-bcf8-1ed2d800d33f-00%40eu-central-1.amazonses.com.


Re: [Django] #34173: SessionMiddleware support 503 status code

2022-11-23 Thread Django
#34173: SessionMiddleware support 503 status code
-+-
 Reporter:  SessionIssue |Owner:  Abhinav
 Type:   |  Yadav
  Cleanup/optimization   |   Status:  assigned
Component:  contrib.sessions |  Version:  4.1
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by SessionIssue):

 Replying to [comment:5 Carlton Gibson]:
 > Happy to look at a patch (with tests) adjusting the check to `if
 response.status_code >= 500:`

 Is this a patch we can expect to see in 3.2 (LTS), or will this only be
 patched in the upcoming 4.2 LTS?
 Thanks in advance.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184a53bc591-8c120828-d48c-4ec8-a689-7c6ae8f62da6-00%40eu-central-1.amazonses.com.


Re: [Django] #34173: SessionMiddleware support 503 status code

2022-11-22 Thread Django
#34173: SessionMiddleware support 503 status code
-+-
 Reporter:  SessionIssue |Owner:  Abhinav
 Type:   |  Yadav
  Cleanup/optimization   |   Status:  assigned
Component:  contrib.sessions |  Version:  4.1
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Abhinav Yadav):

 * owner:  nobody => Abhinav Yadav
 * status:  new => assigned


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184a295d496-fae90e04-2b20-4dea-8bbc-3788b6bbe8d6-00%40eu-central-1.amazonses.com.


Re: [Django] #34173: SessionMiddleware support 503 status code

2022-11-22 Thread Django
#34173: SessionMiddleware support 503 status code
--+
 Reporter:  SessionIssue  |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  contrib.sessions  |  Version:  4.1
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  1 |UI/UX:  0
--+
Changes (by Carlton Gibson):

 * easy:  0 => 1


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701849f94ed4a-659c921c-8d30-4b31-8f57-c3377d1c6ccf-00%40eu-central-1.amazonses.com.


Re: [Django] #34173: SessionMiddleware support 503 status code

2022-11-22 Thread Django
#34173: SessionMiddleware support 503 status code
--+
 Reporter:  SessionIssue  |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  contrib.sessions  |  Version:  4.1
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Carlton Gibson):

 * type:  New feature => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 Happy to look at a patch (with tests) adjusting the check to `if
 response.status_code >= 500:`

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701849f943606-626e5c95-719b-43e8-bf67-5bd1f98956e6-00%40eu-central-1.amazonses.com.


Re: [Django] #34173: SessionMiddleware support 503 status code

2022-11-22 Thread Django
#34173: SessionMiddleware support 503 status code
--+--
 Reporter:  SessionIssue  |Owner:  nobody
 Type:  New feature   |   Status:  new
Component:  contrib.sessions  |  Version:  4.1
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--

Comment (by SessionIssue):

 Replying to [comment:3 Mariusz Felisiak]:
 > I'm not sure why we should treat 503 differently. IMO, we could
 reconsider avoiding session saving when status code > 500 樂
 >
 > PS. Do not reopen tickets without further explanation.

 That would fix the problem and seems like a convenient solution to me.
 Thanks a lot! 

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701849ef41114-04a5057a-8c75-4fad-ac4d-db4254bcaf6b-00%40eu-central-1.amazonses.com.


Re: [Django] #34173: SessionMiddleware support 503 status code

2022-11-22 Thread Django
#34173: SessionMiddleware support 503 status code
--+--
 Reporter:  SessionIssue  |Owner:  nobody
 Type:  New feature   |   Status:  new
Component:  contrib.sessions  |  Version:  4.1
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Changes (by Mariusz Felisiak):

 * cc: Florian Apolloner, Anssi Kääriäinen (added)


Comment:

 I'm not sure why we should treat 503 differently. IMO, we could reconsider
 avoiding session saving when status code > 500 樂

 PS. Do not reopen tickets without further explanation.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701849eb5d3dc-af6b17ee-b60f-4a9a-bc50-5698ae36a62c-00%40eu-central-1.amazonses.com.


Re: [Django] #34173: SessionMiddleware support 503 status code (was: SessionMiddleware only returns 400 or 500 error in case of DB issues.)

2022-11-22 Thread Django
#34173: SessionMiddleware support 503 status code
--+--
 Reporter:  SessionIssue  |Owner:  nobody
 Type:  New feature   |   Status:  new
Component:  contrib.sessions  |  Version:  4.1
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Changes (by SessionIssue):

 * status:  closed => new
 * type:  Bug => New feature
 * resolution:  invalid =>


Old description:

> Hi guys,
>
> I have the following situation. In one of my applications I'm having an
> issue with returning the right status code.
> 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.
> 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:
>
> {{{
> if response.status_code != 500:
> try:
> request.session.save()
> except UpdateError:
> raise SessionInterrupted(
> "The request's session was deleted before the
> "
> "request completed. The user may have logged
> "
> "out in a concurrent request, for example."
> )
> response.set_cookie(
> settings.SESSION_COOKIE_NAME,
> request.session.session_key, max_age=max_age,
> expires=expires,
> domain=settings.SESSION_COOKIE_DOMAIN,
> path=settings.SESSION_COOKIE_PATH,
> secure=settings.SESSION_COOKIE_SECURE or None,
> httponly=settings.SESSION_COOKIE_HTTPONLY or
> None,
> samesite=settings.SESSION_COOKIE_SAMESITE,
> )
> }}}
> As my DB is offline, this results in a 400 error, as the session can't be
> saved.
> I rewrote this small piece in a custom middleware that inherits the
> SessionMiddleware, but this is not a futureproof solution:
>
> {{{
> **if response.status_code not in [500, 503]:**
> try:
> request.session.save()
> except UpdateError:
> raise SessionInterrupted(
> "The request's session was deleted before the
> "
> "request completed. The user may have logged
> "
> "out in a concurrent request, for example."
> )
> response.set_cookie(
> settings.SESSION_COOKIE_NAME,
> request.session.session_key, max_age=max_age,
> expires=expires,
> domain=settings.SESSION_COOKIE_DOMAIN,
> path=settings.SESSION_COOKIE_PATH,
> secure=settings.SESSION_COOKIE_SECURE or None,
> httponly=settings.SESSION_COOKIE_HTTPONLY or
> None,
> samesite=settings.SESSION_COOKIE_SAMESITE,
> )
> }}}
>
> It's a small change, but it will make it hard for us to keep track of all
> the Django updates.
>
> Do you have a generic solution for this issue?
>
> Thanks in advance.

New description:

 Hi guys,

 I have the following situation. In one of my applications I'm having an
 issue with returning the right status code.
 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.
 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).

 {{{
 if response.status_code != 500:
 try:
 request.session.save()
 except UpdateError:
 raise SessionInterrupted(
 "The request's session was deleted before the