Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kazhuu opened this issue May 26, 2025 · 2 comments

Comments

@Kazhuu
Copy link

Kazhuu commented May 26, 2025

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.

@cantin-f
Copy link

#900

@Kazhuu
Copy link
Author

Kazhuu commented May 28, 2025

Thank you! I'll just then wait for the new release!

@Kazhuu Kazhuu closed this as completed May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants