[Django] #28066: SessionBase.cycle_key may discard session data

74 views
Skip to first unread message

Django

unread,
Apr 10, 2017, 10:19:23 PM4/10/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key may discard session data
--------------------------------------------+------------------------
Reporter: InvalidInterrupt | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
--------------------------------------------+------------------------
The `cycle_key()` method will use an empty `dict` for session data if it
had not previously been loaded. The docstring says the function is there
specifically to avoid losing sesison data, and the behavior feels
inconsistent. This won't be noticed on most sites, as the
`AuthenticationMiddleware` accesses the session on every request. However,
it did cause problems for me in unittests for some views.

--
Ticket URL: <https://code.djangoproject.com/ticket/28066>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 11, 2017, 8:33:30 AM4/11/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key may discard session data
----------------------------------+--------------------------------------

Reporter: InvalidInterrupt | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: 1.11
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 Tim Graham):

* easy: 1 => 0


Comment:

Could you please give an example test that demonstrates the issue?

--
Ticket URL: <https://code.djangoproject.com/ticket/28066#comment:1>

Django

unread,
Apr 11, 2017, 9:00:36 PM4/11/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key may discard session data
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner:
| InvalidInterrupt
Type: Bug | Status: assigned
Component: contrib.sessions | Version: 1.11
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 InvalidInterrupt):

* owner: nobody => InvalidInterrupt
* status: new => assigned


Comment:

The first commit in
[https://github.com/InvalidInterrupt/django/tree/ticket_28066] modifies an
existing check for this situation to fail if data is lost. I also went
ahead and quickly wrote a patch for the issue. I'll submit a pull request
if you also believe this is a bug.

--
Ticket URL: <https://code.djangoproject.com/ticket/28066#comment:2>

Django

unread,
Apr 12, 2017, 11:56:00 AM4/12/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key() discards session data if _session_cache isn't
populated

-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner:
| InvalidInterrupt
Type: Bug | Status: assigned
Component: contrib.sessions | Version: 1.11
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 Tim Graham):

* stage: Unreviewed => Accepted


Comment:

Looks okay at first glance. The previous change
(887f3d3219b9f8192d27314eceee27ab1f89c5cc) was new in 1.11 so this could
be backported.

--
Ticket URL: <https://code.djangoproject.com/ticket/28066#comment:3>

Django

unread,
Apr 12, 2017, 4:54:03 PM4/12/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key() discards session data if _session_cache isn't
populated
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner:
| InvalidInterrupt
Type: Bug | Status: assigned
Component: contrib.sessions | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by InvalidInterrupt):

* has_patch: 0 => 1


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/28066#comment:4>

Django

unread,
Apr 17, 2017, 10:28:02 PM4/17/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key() discards session data if _session_cache isn't
populated
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner:
| InvalidInterrupt
Type: Bug | Status: closed
Component: contrib.sessions | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"dda596ca3296f5b2574cf4876a4e176594f52834" dda596c]:
{{{
#!CommitTicketReference repository=""
revision="dda596ca3296f5b2574cf4876a4e176594f52834"
Fixed #28066 -- Prevented SessionBase.cycle_key() from discarding data.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28066#comment:5>

Django

unread,
Apr 17, 2017, 10:42:37 PM4/17/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key() discards session data if _session_cache isn't
populated
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner:
| InvalidInterrupt
Type: Bug | Status: closed
Component: contrib.sessions | Version: 1.11

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"5d556d2aaf64a4181b121e3cb51009d59f02869e" 5d556d2a]:
{{{
#!CommitTicketReference repository=""
revision="5d556d2aaf64a4181b121e3cb51009d59f02869e"
[1.11.x] Fixed #28066 -- Prevented SessionBase.cycle_key() from discarding
data.

Backport of dda596ca3296f5b2574cf4876a4e176594f52834 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28066#comment:6>

Django

unread,
Apr 18, 2017, 11:57:11 AM4/18/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key() discards session data if _session_cache isn't
populated
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner:
| InvalidInterrupt
Type: Bug | Status: closed
Component: contrib.sessions | Version: 1.11

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"81f844940279140d27578fc6a5b134763ffcceb6" 81f84494]:
{{{
#!CommitTicketReference repository=""
revision="81f844940279140d27578fc6a5b134763ffcceb6"
Refs #28066 -- Fixed nondeterministic ordering test failure in
sessions_tests.

Thanks Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28066#comment:7>

Django

unread,
Apr 18, 2017, 12:04:17 PM4/18/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key() discards session data if _session_cache isn't
populated
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner:
| InvalidInterrupt
Type: Bug | Status: closed
Component: contrib.sessions | Version: 1.11

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"3173d9a850043b31eefbb8b1dbc1e66cbdf31a15" 3173d9a]:
{{{
#!CommitTicketReference repository=""
revision="3173d9a850043b31eefbb8b1dbc1e66cbdf31a15"
[1.11.x] Refs #28066 -- Fixed nondeterministic ordering test failure in
sessions_tests.

Thanks Tim Graham for the review.

Backport of 81f844940279140d27578fc6a5b134763ffcceb6 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28066#comment:8>

Django

unread,
Apr 19, 2017, 8:36:27 AM4/19/17
to django-...@googlegroups.com
#28066: SessionBase.cycle_key() discards session data if _session_cache isn't
populated
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner:
| InvalidInterrupt
Type: Bug | Status: closed
Component: contrib.sessions | Version: 1.11

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d6524088a85a3b6ee4216c46a2d847eb6500decd" d6524088]:
{{{
#!CommitTicketReference repository=""
revision="d6524088a85a3b6ee4216c46a2d847eb6500decd"
[1.11.x] Refs #28066 -- Fixed Python 2 failures in sessions_tests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28066#comment:9>

Reply all
Reply to author
Forward
0 new messages