docker-mailman icon indicating copy to clipboard operation
docker-mailman copied to clipboard

django.template Exception while resolving variable '' in template ''

Open almereyda opened this issue 7 years ago • 4 comments

We, @gandhiano and me, find certain combinations of errors when deploying this set of containers. After invoking mailman aliases and trying to Sign up or Log in, we encountered timeout errors on those routes without understandable tracebacks for us. The following errors appear repeatingly, but are only represented with the most notable examples.

Login example

uwsgi.log reports

[pid: 27|app: 0|req: 30/30] 2.164.20.235 () {56 vars in 1129 bytes} [Fri Jul  7 20:45:03 2017] POST /accounts/login/ => generated 0 bytes in 254529 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

mailmanweb.log and uwsgi-error.log additionally report

DEBUG 2017-07-06 23:34:35,653 50 django.template Exception while resolving variable 'next' in template 'account/login.html'.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
VariableDoesNotExist: Failed lookup for key [next] in u"[{'False': False, 'None': None, 'True': True}, {u'csrf_token': <SimpleLazyObject: <function _get_val at 0x7f8fcb548578>>, u'site_name': u'example.com', u'LOGOUT_URL': 'account_logout', 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7f8fcb587410>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7f8fcb5873d0>, 'use_mockups': None, u'request': <WSGIRequest: GET '/accounts/login/?next=/postorius/lists/'>, u'TIME_ZONE': 'UTC', u'STATIC_URL': '/static/', u'LANGUAGES': [(u'af', u'Afrikaans'), (u'ar', u'Arabic'), (u'ast', u'Asturian'), (u'az', u'Azerbaijani'), (u'bg', u'Bulgarian'), (u'be', u'Belarusian'), (u'bn', u'Bengali'), (u'br', u'Breton'), (u'bs', u'Bosnian'), (u'ca', u'Catalan'), (u'cs', u'Czech'), (u'cy', u'Welsh'), (u'da', u'Danish'), (u'de', u'German'), (u'dsb', u'Lower Sorbian'), (u'el', u'Greek'), (u'en', u'English'), (u'en-au', u'Australian English'), (u'en-gb', u'British English'), (u'eo', u'Esperanto'), (u'es', u'Spanish'), (u'es-ar', u'Argentinian Spanish'), (u'es-co', u'Colombian Spanish'), (u'es-mx', u'Mexican Spanish'), (u'es-ni', u'Nicaraguan Spanish'), (u'es-ve', u'Venezuelan Spanish'), (u'et', u'Estonian'), (u'eu', u'Basque'), (u'fa', u'Persian'), (u'fi', u'Finnish'), (u'fr', u'French'), (u'fy', u'Frisian'), (u'ga', u'Irish'), (u'gd', u'Scottish Gaelic'), (u'gl', u'Galician'), (u'he', u'Hebrew'), (u'hi', u'Hindi'), (u'hr', u'Croatian'), (u'hsb', u'Upper Sorbian'), (u'hu', u'Hungarian'), (u'ia', u'Interlingua'), (u'id', u'Indonesian'), (u'io', u'Ido'), (u'is', u'Icelandic'), (u'it', u'Italian'), (u'ja', u'Japanese'), (u'ka', u'Georgian'), (u'kk', u'Kazakh'), (u'km', u'Khmer'), (u'kn', u'Kannada'), (u'ko', u'Korean'), (u'lb', u'Luxembourgish'), (u'lt', u'Lithuanian'), (u'lv', u'Latvian'), (u'mk', u'Macedonian'), (u'ml', u'Malayalam'), (u'mn', u'Mongolian'), (u'mr', u'Marathi'), (u'my', u'Burmese'), (u'nb', u'Norwegian Bokm\\xe5l'), (u'ne', u'Nepali'), (u'nl', u'Dutch'), (u'nn', u'Norwegian Nynorsk'), (u'os', u'Ossetic'), (u'pa', u'Punjabi'), (u'pl', u'Polish'), (u'pt', u'Portuguese'), (u'pt-br', u'Brazilian Portuguese'), (u'ro', u'Romanian'), (u'ru', u'Russian'), (u'sk', u'Slovak'), (u'sl', u'Slovenian'), (u'sq', u'Albanian'), (u'sr', u'Serbian'), (u'sr-latn', u'Serbian Latin'), (u'sv', u'Swedish'), (u'sw', u'Swahili'), (u'ta', u'Tamil'), (u'te', u'Telugu'), (u'th', u'Thai'), (u'tr', u'Turkish'), (u'tt', u'Tatar'), (u'udm', u'Udmurt'), (u'uk', u'Ukrainian'), (u'ur', u'Urdu'), (u'vi', u'Vietnamese'), (u'zh-hans', u'Simplified Chinese'), (u'zh-hant', u'Traditional Chinese')], 'user': <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7f8fcb5870d0>>, u'LOGIN_URL': 'account_login', u'LANGUAGE_CODE': 'en', 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'WARNING': 30, 'SUCCESS': 25, 'ERROR': 40}, 'HYPERKITTY_VERSION': u'1.1.0', u'INSTALLED_APPS': ('hyperkitty', 'postorius', 'django_mailman3', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'django_gravatar', 'paintstore', 'compressor', 'haystack', 'django_extensions', 'django_q', 'allauth', 'allauth.account', 'allauth.socialaccount'), u'LANGUAGE_BIDI': False, u'MEDIA_URL': u''}, {}, {'compressed': {'name': None}, 'form': <LoginForm bound=False, valid=Unknown, fields=(login;password;remember)>, 'redirect_field_value': u'/postorius/lists/', 'redirect_field_name': 'next', 'signup_url': u'/accounts/signup/?next=%2Fpostorius%2Flists%2F', 'site': <Site: example.com>, u'view': <allauth.account.views.LoginView object at 0x7f8fcb640750>}]"

which hints at the account/login.html template and missing data in allauth.account.views.LoginView.

Signup example

uwsgi.og

[pid: 27|app: 0|req: 3/3] 2.164.20.235 () {50 vars in 1119 bytes} [Fri Jul  7 21:24:32 2017] POST /accounts/signup/ => generated 0 bytes in 254632 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

uwsgi-error.log and mailmanweb.log

DEBUG 2017-07-06 23:34:43,676 50 django.template Exception while resolving variable 'next' in template 'account/signup.html'.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
VariableDoesNotExist: Failed lookup for key [next] in u"[{'False': False, 'None': None, 'True': True}, {u'csrf_token': <SimpleLazyObject: <function _get_val at 0x7f8fcb548668>>, u'site_name': u'example.com', u'LOGOUT_URL': 'account_logout', 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7f8fcb495a10>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7f8fcb495450>, 'use_mockups': None, u'request': <WSGIRequest: GET '/accounts/signup/?next=%2Fpostorius%2Flists%2F'>, u'TIME_ZONE': 'UTC', u'STATIC_URL': '/static/', u'LANGUAGES': [(u'af', u'Afrikaans'), (u'ar', u'Arabic'), (u'ast', u'Asturian'), (u'az', u'Azerbaijani'), (u'bg', u'Bulgarian'), (u'be', u'Belarusian'), (u'bn', u'Bengali'), (u'br', u'Breton'), (u'bs', u'Bosnian'), (u'ca', u'Catalan'), (u'cs', u'Czech'), (u'cy', u'Welsh'), (u'da', u'Danish'), (u'de', u'German'), (u'dsb', u'Lower Sorbian'), (u'el', u'Greek'), (u'en', u'English'), (u'en-au', u'Australian English'), (u'en-gb', u'British English'), (u'eo', u'Esperanto'), (u'es', u'Spanish'), (u'es-ar', u'Argentinian Spanish'), (u'es-co', u'Colombian Spanish'), (u'es-mx', u'Mexican Spanish'), (u'es-ni', u'Nicaraguan Spanish'), (u'es-ve', u'Venezuelan Spanish'), (u'et', u'Estonian'), (u'eu', u'Basque'), (u'fa', u'Persian'), (u'fi', u'Finnish'), (u'fr', u'French'), (u'fy', u'Frisian'), (u'ga', u'Irish'), (u'gd', u'Scottish Gaelic'), (u'gl', u'Galician'), (u'he', u'Hebrew'), (u'hi', u'Hindi'), (u'hr', u'Croatian'), (u'hsb', u'Upper Sorbian'), (u'hu', u'Hungarian'), (u'ia', u'Interlingua'), (u'id', u'Indonesian'), (u'io', u'Ido'), (u'is', u'Icelandic'), (u'it', u'Italian'), (u'ja', u'Japanese'), (u'ka', u'Georgian'), (u'kk', u'Kazakh'), (u'km', u'Khmer'), (u'kn', u'Kannada'), (u'ko', u'Korean'), (u'lb', u'Luxembourgish'), (u'lt', u'Lithuanian'), (u'lv', u'Latvian'), (u'mk', u'Macedonian'), (u'ml', u'Malayalam'), (u'mn', u'Mongolian'), (u'mr', u'Marathi'), (u'my', u'Burmese'), (u'nb', u'Norwegian Bokm\\xe5l'), (u'ne', u'Nepali'), (u'nl', u'Dutch'), (u'nn', u'Norwegian Nynorsk'), (u'os', u'Ossetic'), (u'pa', u'Punjabi'), (u'pl', u'Polish'), (u'pt', u'Portuguese'), (u'pt-br', u'Brazilian Portuguese'), (u'ro', u'Romanian'), (u'ru', u'Russian'), (u'sk', u'Slovak'), (u'sl', u'Slovenian'), (u'sq', u'Albanian'), (u'sr', u'Serbian'), (u'sr-latn', u'Serbian Latin'), (u'sv', u'Swedish'), (u'sw', u'Swahili'), (u'ta', u'Tamil'), (u'te', u'Telugu'), (u'th', u'Thai'), (u'tr', u'Turkish'), (u'tt', u'Tatar'), (u'udm', u'Udmurt'), (u'uk', u'Ukrainian'), (u'ur', u'Urdu'), (u'vi', u'Vietnamese'), (u'zh-hans', u'Simplified Chinese'), (u'zh-hant', u'Traditional Chinese')], 'user': <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7f8fcb495210>>, u'LOGIN_URL': 'account_login', u'LANGUAGE_CODE': 'en', 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'WARNING': 30, 'SUCCESS': 25, 'ERROR': 40}, 'HYPERKITTY_VERSION': u'1.1.0', u'INSTALLED_APPS': ('hyperkitty', 'postorius', 'django_mailman3', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'django_gravatar', 'paintstore', 'compressor', 'haystack', 'django_extensions', 'django_q', 'allauth', 'allauth.account', 'allauth.socialaccount'), u'LANGUAGE_BIDI': False, u'MEDIA_URL': u''}, {}, {'login_url': u'/accounts/login/?next=%2Fpostorius%2Flists%2F', 'form': <SignupForm bound=False, valid=Unknown, fields=(username;email;password1;password2)>, 'redirect_field_value': u'/postorius/lists/', 'compressed': {'name': None}, 'redirect_field_name': 'next', u'view': <allauth.account.views.SignupView object at 0x7f8fcb495290>}]"

pointing fingers at account/signup.html and the allauth.account.views.SignupView. A combination of missing keys and related views was made available with

$ grep "in template" mailmanweb.log | awk '{ print $10 " " $13 }' | sort -u                                                                                                                                             
'add_url' 'admin/index.html'.
'auth_params' 'account/login.html'.
'can_change_related' 'admin/related_widget_wrapper.html'.
'can_delete_related' 'admin/related_widget_wrapper.html'.
'errors' 'admin/change_list.html'.
'is_multipart' 'admin/change_list.html'.
'is_popup' 'admin/app_index.html'.
'is_popup' 'admin/index.html'.
'is_popup' 'admin/login.html'.
'mlist' 'account/login.html'.
'mlist' 'account/logout.html'.
'mlist' 'account/signup.html'.
'mlist' 'hyperkitty/index.html'.
'next' 'account/login.html'.
'next' 'account/signup.html'.
'next' 'hyperkitty/index.html'.
'next' 'postorius/index.html'.
'non_field_errors' 'admin/change_list.html'.
'query' 'account/login.html'.
'query' 'account/logout.html'.
'query' 'account/signup.html'.
'query' 'hyperkitty/index.html'.
'query' 'postorius/lists/members.html'.
'scope' 'account/login.html'.
'show' 'admin/change_list.html'.
'user_request_pending' 'postorius/lists/summary.html'.

Which kinds of triaging, debugging and resolution could help here? For the load balancer, this just looks like a 504 Gateway Time-out:

nginx                | 2017/07/06 15:47:25 [error] 6#6: *52 upstream prematurely closed connection while reading response header from upstream, client: 0.0.0.0, server: mailman.ecobytes.net, request: "POST /accounts/login/ HTTP/1.1", upstream: "http://172.18.0.6:8000/accounts/login/", host: "mailman", referrer: "https://mailman/accounts/login/"

almereyda avatar Jul 08 '17 01:07 almereyda

Probably related to: https://stackoverflow.com/questions/40066019/django-1-10-exception-while-resolving-variable-is-popup-in-template-admin-log comment 2

y0va avatar Jul 08 '17 22:07 y0va

It looks like a problem with either Django or Allauth, I will investigate more and maybe open issues upstream.

maxking avatar Jul 10 '17 22:07 maxking

I get this error in this line <p>{% with site.name as site_name %}Please sign in with one But i'm not sure if there is an easy way to set it up without overriding the default view, which seems strange since it's supposed to work like this by default.

Bulletninja avatar May 09 '19 00:05 Bulletninja

For the load balancer, this just looks like a 504 Gateway Time-out: Seems like it must be 502 Gateway Time-out

fannigurt avatar Sep 27 '19 20:09 fannigurt

This issue has not been updated for more than 1year

github-actions[bot] avatar Nov 23 '22 22:11 github-actions[bot]