Skip to content
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

<asgiref.local.Local object at 0xffff8cab4f90> object has no attribute 'request' #59

Closed
LoFenk opened this issue Nov 13, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@LoFenk
Copy link

LoFenk commented Nov 13, 2023

I'm not sure if this is a django-check-seo issue or a django-simple-history issue. But if I enable the middleware of django-simple-history, it breaks django-check-seo. Either work fine independently but not together so there seems to be a conflict somewhere.

To reproduce the bug, install both apps, and the django-check-seo. Here's the traceback:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:9000/django-check-seo/?page=/

Django Version: 4.2.4
Python Version: 3.11.6
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.sitemaps',
 'django_bootstrap5',
 'compressor',
 'storages',
 'cities_light',
 'simple_history',
 'django_cleanup.apps.CleanupConfig',
 'django_celery_beat',
 'django_check_seo',
 'linkcheck']
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',
 'csp.middleware.CSPMiddleware',
 'simple_history.middleware.HistoryRequestMiddleware',]



Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simple_history/middleware.py", line 37, in middleware
    with _context_manager(request):
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
    ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simple_history/middleware.py", line 16, in _context_manager
    del HistoricalRecords.context.request
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/asgiref/local.py", line 120, in __delattr__
    raise AttributeError(f"{self!r} object has no attribute {key!r}")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception Type: AttributeError at /django-check-seo/
Exception Value: <asgiref.local.Local object at 0xffff8cab4f90> object has no attribute 'request'
@corentinbettiol
Copy link
Member

Hi, I'll take a look :)

@corentinbettiol corentinbettiol added the bug Something isn't working label Nov 13, 2023
@corentinbettiol corentinbettiol self-assigned this Nov 13, 2023
@corentinbettiol
Copy link
Member

Took a look, here's my conclusion.

@corentinbettiol
Copy link
Member

Should be fixed by jazzband/django-simple-history#1256 (available in django-simple-history 3.5.0) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants