[Django] #31592: Can't revert to Django 3.0.6 after running migration for 3.1a1

7 views
Skip to first unread message

Django

unread,
May 15, 2020, 7:16:34 AM5/15/20
to django-...@googlegroups.com
#31592: Can't revert to Django 3.0.6 after running migration for 3.1a1
-----------------------------------------+------------------------
Reporter: אורי | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
I upgraded to Django 3.1a1 and ran migrations. I also created my own
migration because of the change from `from django.contrib.postgres.fields
import JSONField` to `from django.db.models import JSONField`. My own
migration was generated automatically:

{{{
# Generated by Django 3.1a1 on 2020-05-14 16:25

from django.db import migrations, models
import speedy.match.accounts.models


class Migration(migrations.Migration):

dependencies = [
('match_accounts', '0006_auto_20200121_1731'),
]

operations = [
migrations.AlterField(
model_name='siteprofile',
name='diet_match',
field=models.JSONField(default=speedy.match.accounts.models.SiteProfile.diet_match_default,
verbose_name='Diet match'),
),
migrations.AlterField(
model_name='siteprofile',
name='relationship_status_match',
field=models.JSONField(default=speedy.match.accounts.models.SiteProfile.relationship_status_match_default,
verbose_name='Relationship status match'),
),
migrations.AlterField(
model_name='siteprofile',
name='smoking_status_match',
field=models.JSONField(default=speedy.match.accounts.models.SiteProfile.smoking_status_match_default,
verbose_name='Smoking status match'),
),
]
}}}

Most of the things worked with Django 3.1a1 except a few things which I
will report later. But when trying to use Django 3.0.6 again, I ran the
following commands:

{{{
./manage_all_sites.sh migrate auth 0011
./manage_all_sites.sh migrate match_accounts 0006
}}}

Then, after running my websites with Django 3.0.6, I received an error
message:

`Incorrect padding`

I can't run my websites locally without deleting the database completely
including all users. I didn't find any way to fix the database to run it
with Django 3.0.6.

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

Django

unread,
May 15, 2020, 7:17:02 AM5/15/20
to django-...@googlegroups.com
#31592: Can't revert to Django 3.0.6 after running migrations for 3.1a1
-------------------------------+--------------------------------------

Reporter: אורי | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 3.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
-------------------------------+--------------------------------------

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

Django

unread,
May 15, 2020, 8:34:57 AM5/15/20
to django-...@googlegroups.com
#31592: Reverting Django 3.1. to Django 3.0.6 raises "binascii.Error: Incorrect
padding".
------------------------------+--------------------------------------
Reporter: אורי | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 3.1
Severity: Normal | Resolution: invalid

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 felixxm):

* status: new => closed
* resolution: => invalid
* component: Uncategorized => Core (Other)


Comment:

Thanks for this ticket. This error is not related with migrations but with
sessions and changes of a hashing algorithm from the SHA-1 to SHA-256:
{{{
File "django/contrib/sessions/backends/base.py", line 110, in decode
encoded_data = base64.b64decode(session_data.encode('ascii'))
File "python3.6/base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
}}}

To fix this you need to remove sessions from cache, e.g.
{{{
from django.contrib.sessions.models import Session
Session.objects.all().delete()
}}}

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

Django

unread,
May 15, 2020, 8:53:40 AM5/15/20
to django-...@googlegroups.com
#31592: Reverting Django 3.1. to Django 3.0.6 raises "binascii.Error: Incorrect
padding".
------------------------------+--------------------------------------
Reporter: אורי | Owner: nobody

Type: Bug | Status: closed
Component: Core (Other) | Version: 3.1
Severity: Normal | Resolution: invalid
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 אורי):

Does this error also occur if I migrate forward (from 3.0 to 3.1) or only
backwards?

Anyway, I think Django should be able to delete the relevant cache when
migrating (backwards or forward) and not just raise exceptions which don't
make sense to the users. Maybe just check the version of the session
objects and if it's not correct then delete them.

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

Django

unread,
May 15, 2020, 8:56:55 AM5/15/20
to django-...@googlegroups.com
#31592: Reverting Django 3.1. to Django 3.0.6 raises "binascii.Error: Incorrect
padding".
------------------------------+--------------------------------------
Reporter: אורי | Owner: nobody

Type: Bug | Status: closed
Component: Core (Other) | Version: 3.1
Severity: Normal | Resolution: invalid
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 אורי):

Also, does it mean migrating from Django 3.0 to 3.1 will log out all the
users? I use persistent cookies for 30 years and I don't want to log out
users who didn't log out or delete their cookies.

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

Django

unread,
May 15, 2020, 10:12:09 AM5/15/20
to django-...@googlegroups.com
#31592: Reverting Django 3.1. to Django 3.0.6 raises "binascii.Error: Incorrect
padding".
------------------------------+--------------------------------------
Reporter: אורי | Owner: nobody

Type: Bug | Status: closed
Component: Core (Other) | Version: 3.1
Severity: Normal | Resolution: invalid
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 felixxm):

Replying to [comment:3 אורי]:
> Does this error also occur if I migrate forward (from 3.0 to 3.1) ...?
>

No, support for user sessions that use the old hashing algorithm remains
until Django 4.0, see [https://docs.djangoproject.com/en/3.1/releases/3.1
/#django-contrib-auth release notes].

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

Reply all
Reply to author
Forward
0 new messages