Raised a ticket <https://code.djangoproject.com/ticket/31895>
The only workaround is to truncate the django_session table.  (clearsessions
<https://docs.djangoproject.com/en/3.0/ref/django-admin/#django-contrib-sessions>
did not work)

On Mon, 17 Aug 2020 at 21:24, Matthew Hegarty <[email protected]> wrote:

> Hey Diptesh - did you get anywhere with understanding this?  Did y ou get
> any response from the Django devs?
> Just happened to me on my Staging site.  Recently upgraded from 3.0 to 3.1
>
> I can login with Firefox, but Chrome crashes with the following error:
>
> ```python
> Internal Server Error: /home/
> Traceback (most recent call last):
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py",
> line 215, in _get_session
> return self._session_cache
> AttributeError: 'SessionStore' object has no attribute '_session_cache'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py",
> line 118, in decode
> return signing.loads(session_data, salt=self.key_salt,
> serializer=self.serializer)
> File "/usr/local/lib/python3.8/site-packages/django/core/signing.py", line
> 135, in loads
> base64d = TimestampSigner(key, salt=salt).unsign(s,
> max_age=max_age).encode()
> File "/usr/local/lib/python3.8/site-packages/django/core/signing.py", line
> 201, in unsign
> result = super().unsign(value)
> File "/usr/local/lib/python3.8/site-packages/django/core/signing.py", line
> 184, in unsign
> raise BadSignature('Signature "%s" does not match' % sig)
> django.core.signing.BadSignature: Signature
> "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" does not match
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
> File
> "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py",
> line 47, in inner
> response = get_response(request)
> File
> "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line
> 179, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
> File
> "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line
> 73, in view
> return self.dispatch(request, *args, **kwargs)
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/auth/mixins.py",
> line 50, in dispatch
> if not request.user.is_authenticated:
> File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py",
> line 240, in inner
> self._setup()
> File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py",
> line 376, in _setup
> self._wrapped = self._setupfunc()
> File "/usr/local/lib/python3.8/site-packages/django_otp/middleware.py",
> line 38, in _verify_user
> user.otp_device = None
> File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py",
> line 270, in __setattr__
> self._setup()
> File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py",
> line 376, in _setup
> self._wrapped = self._setupfunc()
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/auth/middleware.py",
> line 23, in <lambda>
> request.user = SimpleLazyObject(lambda: get_user(request))
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/auth/middleware.py",
> line 11, in get_user
> request._cached_user = auth.get_user(request)
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/auth/__init__.py",
> line 174, in get_user
> user_id = _get_user_session_key(request)
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/auth/__init__.py",
> line 58, in _get_user_session_key
> return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py",
> line 65, in __getitem__
> return self._session[key]
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py",
> line 220, in _get_session
> self._session_cache = self.load()
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py",
> line 44, in load
> return self.decode(s.session_data) if s else {}
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py",
> line 122, in decode
> return self._legacy_decode(session_data)
> File
> "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py",
> line 126, in _legacy_decode
> encoded_data = base64.b64decode(session_data.encode('ascii'))
> File "/usr/local/lib/python3.8/base64.py", line 87, in b64decode
> return binascii.a2b_base64(s)
> binascii.Error: Incorrect padding
> ```
> On Monday, 10 August 2020 at 12:21:34 UTC+1 Diptesh Choudhuri wrote:
>
>>
>>
>> Environment:
>>
>>
>>
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/admin/
>>
>>
>> Django Version: 3.1
>> Python Version: 3.8.3
>> Installed Applications:
>> ['django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'rest_framework',
>>  'rest_framework.authtoken',
>>  'accounts.apps.AccountsConfig',
>>  'posts.apps.PostsConfig']
>> Installed Middleware:
>> ['django.middleware.security.SecurityMiddleware',
>>  'django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
>>
>>
>>
>>
>>
>>
>> Traceback (most recent call last):
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py"
>> , line 215, in _get_session
>>     return self._session_cache
>>
>>
>> During handling of the above exception ('SessionStore' object has no
>> attribute '_session_cache'), another exception occurred:
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py"
>> , line 118, in decode
>>     return signing.loads(session_data, salt=self.key_salt, serializer=
>> self.serializer)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/core/signing.py"
>> , line 135, in loads
>>     base64d = TimestampSigner(key, salt=salt).unsign(s, max_age=max_age).
>> encode()
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/core/signing.py"
>> , line 201, in unsign
>>     result = super().unsign(value)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/core/signing.py"
>> , line 184, in unsign
>>     raise BadSignature('Signature "%s" does not match' % sig)
>>
>>
>> During handling of the above exception (Signature
>> "JKiu07_FryzGGxaZmuA9hc0WmtZKBMOOeOj3Fp3j8ho" does not match), another
>> exception occurred:
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/core/handlers/exception.py"
>> , line 47, in inner
>>     response = get_response(request)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/core/handlers/base.py"
>> , line 179, in _get_response
>>     response = wrapped_callback(request, *callback_args, **
>> callback_kwargs)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/admin/sites.py"
>> , line 251, in wrapper
>>     return self.admin_view(view, cacheable)(*args, **kwargs)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/utils/decorators.py"
>> , line 130, in _wrapped_view
>>     response = view_func(request, *args, **kwargs)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/views/decorators/cache.py"
>> , line 44, in _wrapped_view_func
>>     response = view_func(request, *args, **kwargs)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/admin/sites.py"
>> , line 222, in inner
>>     if not self.has_permission(request):
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/admin/sites.py"
>> , line 196, in has_permission
>>     return request.user.is_active and request.user.is_staff
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/utils/functional.py"
>> , line 240, in inner
>>     self._setup()
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/utils/functional.py"
>> , line 376, in _setup
>>     self._wrapped = self._setupfunc()
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/auth/middleware.py"
>> , line 23, in <lambda>
>>     request.user = SimpleLazyObject(lambda: get_user(request))
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/auth/middleware.py"
>> , line 11, in get_user
>>     request._cached_user = auth.get_user(request)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/auth/__init__.py"
>> , line 174, in get_user
>>     user_id = _get_user_session_key(request)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/auth/__init__.py"
>> , line 58, in _get_user_session_key
>>     return get_user_model()._meta.pk.to_python(request.session[
>> SESSION_KEY])
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py"
>> , line 65, in __getitem__
>>     return self._session[key]
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py"
>> , line 220, in _get_session
>>     self._session_cache = self.load()
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py"
>> , line 44, in load
>>     return self.decode(s.session_data) if s else {}
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py"
>> , line 122, in decode
>>     return self._legacy_decode(session_data)
>>   File
>> "/home/ignisda/.cache/pypoetry/virtualenvs/backend-3DENPaHW-py3.8/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py"
>> , line 126, in _legacy_decode
>>     encoded_data = base64.b64decode(session_data.encode('ascii'))
>>   File "/usr/lib/python3.8/base64.py", line 87, in b64decode
>>     return binascii.a2b_base64(s)
>>
>>
>> Exception Type: Error at /admin/
>> Exception Value: Incorrect padding
>>
>>
>> This happened first when I was developing on my Android device using
>> Termux app. I switched my browser to Google-Chrome and the issue was
>> resolved.
>> Then today I was developing on my PC, using qutebrowser and this error
>> popped up again. Switching to Google-Chrome fixed the issue.
>>
>> I don't think this is an issue with the browsers themselves, because I
>> have completed entire django projects in both these devices, and never had
>> to switch to Chrome.
>>
>> The only differences happen to be- This is my first time using
>> djangorestframework, first time using django 3.1
>>
>> Is this a bug that has leaked into django 3.1 inadvertently?
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/PExKciSIqeU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9356132f-625e-4556-8107-c8de70a0c540n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9356132f-625e-4556-8107-c8de70a0c540n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAcKVnk9hAfrML%2BXNR_amdqTxcPWPpe%3DOUUxLR6X44RdU2wXcQ%40mail.gmail.com.

Reply via email to