modoboa / modoboa-webmail

The webmail of Modoboa
MIT License
76 stars 47 forks source link

UnboundLocalError at /webmail/ local variable 'data' referenced before assignment #233

Closed x-raf closed 2 years ago

x-raf commented 2 years ago

### After updating Ubuntu to 22.04, manual reinstall of modoboa, webmail,contacts and calendars pages with errors Any ideas what went wrong?

Screenshot 2022-04-30 at 20 38 14

Environment:

Request Method: GET
Request URL: https://mail.rafaldaczko.photography/webmail/

Django Version: 2.2.28
Python Version: 3.10.4
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'reversion',
 'ckeditor',
 'ckeditor_uploader',
 'rest_framework',
 'rest_framework.authtoken',
 'phonenumber_field',
 'django_otp',
 'django_otp.plugins.otp_totp',
 'django_otp.plugins.otp_static',
 'modoboa',
 'modoboa.core',
 'modoboa.lib',
 'modoboa.admin',
 'modoboa.transport',
 'modoboa.relaydomains',
 'modoboa.limits',
 'modoboa.parameters',
 'modoboa.dnstools',
 'modoboa.policyd',
 'modoboa.maillog',
 'modoboa_amavis',
 'modoboa_pdfcredentials',
 'modoboa_postfix_autoreply',
 'modoboa_sievefilters',
 'modoboa_webmail',
 'modoboa_contacts',
 'modoboa_radicale',
 'webpack_loader')
Installed Middleware:
('x_forwarded_for.middleware.XForwardedForMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django_otp.middleware.OTPMiddleware',
 'modoboa.core.middleware.TwoFAMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'modoboa.core.middleware.LocalConfigMiddleware',
 'modoboa.lib.middleware.AjaxLoginRedirect',
 'modoboa.lib.middleware.CommonExceptionCatcher',
 'modoboa.lib.middleware.RequestCatcherMiddleware',
 'django.middleware.security.SecurityMiddleware')

Traceback:

File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa_webmail/lib/imaputils.py" in getquota
  686.             data = self._cmd("GETQUOTAROOT", self._encode_mbox_name(mailbox),

File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa_webmail/lib/imaputils.py" in _encode_mbox_name
  415.         return b'"' + folder.encode("imap4-utf-7") + b'"'

During handling of the above exception (unknown encoding: imap4-utf-7), another exception occurred:

File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/handlers/base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/lib/python3.10/contextlib.py" in inner
  79.                 return func(*args, **kwds)

File "/usr/lib/python3.10/contextlib.py" in inner
  79.                 return func(*args, **kwds)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  21.                 return view_func(request, *args, **kwargs)

File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/lib.py" in wrapped_f
  40.                 return f(request, *args, **kwargs)

File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa_webmail/views.py" in index
  662.         imapc.getquota(curmbox)

File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa_webmail/lib/imaputils.py" in getquota
  691.             if data is None:

Exception Type: UnboundLocalError at /webmail/
Exception Value: local variable 'data' referenced before assignment

Screenshot 2022-04-30 at 20 38 55

Environment:

Request Method: GET
Request URL: https://mail.rafaldaczko.photography/contacts/

Django Version: 2.2.28
Python Version: 3.10.4
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'reversion',
 'ckeditor',
 'ckeditor_uploader',
 'rest_framework',
 'rest_framework.authtoken',
 'phonenumber_field',
 'django_otp',
 'django_otp.plugins.otp_totp',
 'django_otp.plugins.otp_static',
 'modoboa',
 'modoboa.core',
 'modoboa.lib',
 'modoboa.admin',
 'modoboa.transport',
 'modoboa.relaydomains',
 'modoboa.limits',
 'modoboa.parameters',
 'modoboa.dnstools',
 'modoboa.policyd',
 'modoboa.maillog',
 'modoboa_amavis',
 'modoboa_pdfcredentials',
 'modoboa_postfix_autoreply',
 'modoboa_sievefilters',
 'modoboa_webmail',
 'modoboa_contacts',
 'modoboa_radicale',
 'webpack_loader')
Installed Middleware:
('x_forwarded_for.middleware.XForwardedForMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django_otp.middleware.OTPMiddleware',
 'modoboa.core.middleware.TwoFAMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'modoboa.core.middleware.LocalConfigMiddleware',
 'modoboa.lib.middleware.AjaxLoginRedirect',
 'modoboa.lib.middleware.CommonExceptionCatcher',
 'modoboa.lib.middleware.RequestCatcherMiddleware',
 'django.middleware.security.SecurityMiddleware')

Traceback:

File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/handlers/base.py" in _get_response
  145.                 response = self.process_exception_by_middleware(e, request)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/handlers/base.py" in _get_response
  143.                 response = response.render()

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/response.py" in render
  106.             self.content = self.rendered_content

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/response.py" in rendered_content
  83.         content = template.render(context, self._request)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/backends/django.py" in render
  61.             return self.template.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  171.                     return self._render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/loader_tags.py" in render
  150.             return compiled_parent._render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/loader_tags.py" in render
  150.             return compiled_parent._render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/loader_tags.py" in render
  62.                 result = block.nodelist.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/defaulttags.py" in render
  312.                 return nodelist.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/library.py" in render
  192.         output = self.func(*resolved_args, **resolved_kwargs)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/templatetags/webpack_loader.py" in render_bundle
  20.     tags = utils.get_as_tags(

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/utils.py" in get_as_tags
  63.     bundle = _get_bundle(loader, bundle_name, extension)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/utils.py" in _get_bundle
  39.     bundle = loader.get_bundle(bundle_name)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/loader.py" in get_bundle
  116.             filtered_chunks = self.filter_chunks(chunks)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/loader.py" in filter_chunks
  58.             ignore = any(regex.match(chunk)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/loader.py" in <genexpr>
  58.             ignore = any(regex.match(chunk)

Exception Type: TypeError at /contacts/
Exception Value: expected string or bytes-like object

Screenshot 2022-04-30 at 20 39 51

Environment:

Request Method: GET
Request URL: https://mail.rafaldaczko.photography/calendars/

Django Version: 2.2.28
Python Version: 3.10.4
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'reversion',
 'ckeditor',
 'ckeditor_uploader',
 'rest_framework',
 'rest_framework.authtoken',
 'phonenumber_field',
 'django_otp',
 'django_otp.plugins.otp_totp',
 'django_otp.plugins.otp_static',
 'modoboa',
 'modoboa.core',
 'modoboa.lib',
 'modoboa.admin',
 'modoboa.transport',
 'modoboa.relaydomains',
 'modoboa.limits',
 'modoboa.parameters',
 'modoboa.dnstools',
 'modoboa.policyd',
 'modoboa.maillog',
 'modoboa_amavis',
 'modoboa_pdfcredentials',
 'modoboa_postfix_autoreply',
 'modoboa_sievefilters',
 'modoboa_webmail',
 'modoboa_contacts',
 'modoboa_radicale',
 'webpack_loader')
Installed Middleware:
('x_forwarded_for.middleware.XForwardedForMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django_otp.middleware.OTPMiddleware',
 'modoboa.core.middleware.TwoFAMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'modoboa.core.middleware.LocalConfigMiddleware',
 'modoboa.lib.middleware.AjaxLoginRedirect',
 'modoboa.lib.middleware.CommonExceptionCatcher',
 'modoboa.lib.middleware.RequestCatcherMiddleware',
 'django.middleware.security.SecurityMiddleware')

Traceback:

File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/handlers/base.py" in _get_response
  145.                 response = self.process_exception_by_middleware(e, request)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/handlers/base.py" in _get_response
  143.                 response = response.render()

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/response.py" in render
  106.             self.content = self.rendered_content

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/response.py" in rendered_content
  83.         content = template.render(context, self._request)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/backends/django.py" in render
  61.             return self.template.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  171.                     return self._render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/loader_tags.py" in render
  150.             return compiled_parent._render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/loader_tags.py" in render
  150.             return compiled_parent._render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/loader_tags.py" in render
  62.                 result = block.nodelist.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/srv/modoboa/env/lib/python3.10/site-packages/django/template/library.py" in render
  192.         output = self.func(*resolved_args, **resolved_kwargs)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/templatetags/webpack_loader.py" in render_bundle
  20.     tags = utils.get_as_tags(

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/utils.py" in get_as_tags
  63.     bundle = _get_bundle(loader, bundle_name, extension)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/utils.py" in _get_bundle
  39.     bundle = loader.get_bundle(bundle_name)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/loader.py" in get_bundle
  116.             filtered_chunks = self.filter_chunks(chunks)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/loader.py" in filter_chunks
  58.             ignore = any(regex.match(chunk)

File "/srv/modoboa/env/lib/python3.10/site-packages/webpack_loader/loader.py" in <genexpr>
  58.             ignore = any(regex.match(chunk)

Exception Type: TypeError at /calendars/
Exception Value: expected string or bytes-like object
tonioo commented 2 years ago

Duplicate of #224

x-raf commented 2 years ago

@tonioo what about contacts and calendars page? Is there also a solution for those errors? #227 solution work perfect