#22426 closed Bug (fixed)
Django >= 1.6.0 can't handle old style messages cookie
Reported by: | iivvoo | Owned by: | ofirov |
---|---|---|---|
Component: | contrib.messages | Version: | 1.6 |
Severity: | Release blocker | Keywords: | messages, cookie, 1.4 |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The message cookie format has changed in Django 1.5.x, Django 1.6.x no longer supports the old format.
If you upgrade your project from Django 1.4.x directly to 1.6.x (skipping the 1.5 release), your application will fail quickly on old-style message cookies:
Exception Type: IndexError Exception Value: list index out of range Exception Location: (...) django/contrib/messages/storage/cookie.py in process_messages, line 37
Django 1.5 contained some backward compatibility to handle both styles:
https://github.com/django/django/commit/9e7183073f64e541587e8dcfd8bb3ddeb47f8162
but this code is no longer present in Django 1.6.2
Since you can't ask all your users to delete their cookies if they run into this error, there's no easy/quick workaround.
It's not uncommon for projects to skip a version. Also, Django 1.4.x is LTS and people may jump from LTS release to LTS release, which means they will also run into this issue.
Change History (7)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | 1.6 → master |
Since the backwards compat code is only 2 lines, I'd leave it in there at least till the next LTS. Needs backport to 1.6+
comment:3 Changed 10 years ago by
Has patch: | set |
---|---|
Owner: | changed from nobody to ofirov |
Status: | new → assigned |
Version: | master → 1.6 |
I just sent a pull request for a fix for this:
https://github.com/django/django/pull/2559
I added it to 1.6 and left it out of master.
comment:4 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
FWIW I've created a small piece of middleware as a workaround: http://vanderwijk.info/blog/workaround-django-1-4-django-1-6-message-cookie-error
but the real fix is to simply restore the backward compatibility from Django 1.5