Skip to content

Using OutstandingToken model causes attribute missing error when blacklist app is not enabled during token refresh. #914

Closed
@Kazhuu

Description

@Kazhuu

Hello! Thank you for such a nice library!

Recently we updated our Python libraries and it seems that the latest version 5.5.0 causes following stack trace when the blacklist app is not enabled for the project: https://django-rest-framework-simplejwt.readthedocs.io/en/latest/blacklist_app.html. This error happens during the token refresh. When I enable the blacklist app and run manage.py migrate, the error goes away.

ERROR Internal Server Error: /token/refresh/
Traceback (most recent call last):
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/rest_framework/views.py", line 515, in dispatch
    response = self.handle_exception(exc)
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/rest_framework/views.py", line 475, in handle_exception
    self.raise_uncaught_exception(exc)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/rest_framework/views.py", line 486, in raise_uncaught_exception
    raise exc
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/rest_framework/views.py", line 512, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/rest_framework_simplejwt/views.py", line 44, in post
    serializer.is_valid(raise_exception=True)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/rest_framework/serializers.py", line 225, in is_valid
    self._validated_data = self.run_validation(self.initial_data)
                           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/rest_framework/serializers.py", line 447, in run_validation
    value = self.validate(value)
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/rest_framework_simplejwt/serializers.py", line 141, in validate
    refresh.outstand()
    ~~~~~~~~~~~~~~~~^^
  File "/home/kazhuu/programming/backend/.venv/lib/python3.13/site-packages/rest_framework_simplejwt/tokens.py", line 222, in outstand
    return OutstandingToken.objects.get_or_create(
           ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'OutstandingToken' has no attribute 'objects'

It seems there should be some check in that part of the to check if OutstandingTokens available or not.

I tried to look the existing issues but did not find this being reported. I could also provide a fix for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions