#31592 closed Bug (invalid)
Reverting Django 3.1. to Django 3.0.6 raises "binascii.Error: Incorrect padding".
Reported by: | אורי | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 3.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (5)
comment:1 by , 5 years ago
Summary: | Can't revert to Django 3.0.6 after running migration for 3.1a1 → Can't revert to Django 3.0.6 after running migrations for 3.1a1 |
---|
comment:2 by , 5 years ago
Component: | Uncategorized → Core (Other) |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Summary: | Can't revert to Django 3.0.6 after running migrations for 3.1a1 → Reverting Django 3.1. to Django 3.0.6 raises "binascii.Error: Incorrect padding". |
follow-up: 5 comment:3 by , 5 years ago
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.
comment:4 by , 5 years ago
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.
comment:5 by , 5 years ago
Replying to אורי:
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 release notes.
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:
To fix this you need to remove sessions from cache, e.g.