Different Mail Domain Cause Key Error
I have a client that requires his list address to be list@domain.com. But since he is using domain.com for an external website, he has to access his list via Postorius using list.domain.com. So here is what I did:
Django Admin Add Site: list.domain.com Add Mail Domain: domain.com (Site selected is list.domain.com)
Postorius Add Domain: Mailhost is domain.com. Web Host is list.domain.com (list.domain.com).
I have list.domain.com listed in the allowed hosts in settings_local.py. I even added domain.com there as well.
When I try to access Postorius using list.domain.com I get a "An error occurred while processing your request." message and the logs shows the dreaded:
'Internal Server Error: /mailman3/lists/
KeyError at /mailman3/lists/
'file'
Did I miss a step here?
Thanks, Brian
On 4/21/20 12:49 PM, Brian Carpenter wrote:
When I try to access Postorius using list.domain.com I get a "An error occurred while processing your request." message and the logs shows the dreaded:
'Internal Server Error: /mailman3/lists/ KeyError at /mailman3/lists/ 'file'
This is not the error. The KeyError ... 'file' exception is a Django logging exception. It is not the underlying error. There should be more in the log indicating what the real problem is.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 4/21/20 4:04 PM, Mark Sapiro wrote:
This is not the error. The KeyError ... 'file' exception is a Django logging exception. It is not the underlying error. There should be more in the log indicating what the real problem is.
Ok. The first thing however is did I miss a step?
Here is the complete error that is sent to me via email as superuser:
Internal Server Error:/mailman3/lists/
KeyError at/mailman3/lists/ 'file'
Traceback:
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/postorius/views/list.py" in list_index 755. paginator_class=MailmanPaginator)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django_mailman3/lib/paginator.py" in paginate 71. objects = paginator.page(page_num)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django_mailman3/lib/paginator.py" in page 46. number = self.validate_number(number)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/paginator.py" in validate_number 48. if number > self.num_pages:
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/utils/functional.py" in __get__ 80. res = instance.__dict__[self.name] = self.func(instance)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/paginator.py" in num_pages 97. if self.count == 0 and not self.allow_empty_first_page:
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/utils/functional.py" in __get__ 80. res = instance.__dict__[self.name] = self.func(instance)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django_mailman3/lib/paginator.py" in count 56. return self.function(count=0, page=1).total_size
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/postorius/views/list.py" in _get_list_page 751. advertised=advertised, mail_host=mail_host, count=count, page=page)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailmanclient/client.py" in get_list_page 181. return Page(self._connection, url, MailingList, count, page)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailmanclient/restbase/page.py" in __init__ 37. self._create_page()
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailmanclient/restbase/page.py" in _create_page 62. response, content = self._connection.call(self._build_url())
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailmanclient/restbase/connection.py" in call 112. error_msg, response, None)
*During handling of the above exception (HTTP Error 404: {"title": "404 Not Found"}), another exception occurred:*
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/postorius/middleware.py" in __call__ 42. return self.get_response(request)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner 36. response = response_for_exception(request, exc)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/handlers/exception.py" in response_for_exception 95. exc_info=sys.exc_info(),
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/utils/log.py" in log_response 228. exc_info=exc_info,
File "/usr/lib/python3.7/logging/__init__.py" in error 1412. self._log(ERROR, msg, args, **kwargs)
File "/usr/lib/python3.7/logging/__init__.py" in _log 1519. self.handle(record)
File "/usr/lib/python3.7/logging/__init__.py" in handle 1529. self.callHandlers(record)
File "/usr/lib/python3.7/logging/__init__.py" in callHandlers 1591. hdlr.handle(record)
File "/usr/lib/python3.7/logging/__init__.py" in handle 905. self.emit(record)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/utils/log.py" in emit 119. reporter = ExceptionReporter(request, is_email=True, *exc_info)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/views/debug.py" in __init__ 254. self.template_info = getattr(self.exc_value, 'template_debug', None)
File "/usr/lib/python3.7/tempfile.py" in __getattr__ 614. file = self.__dict__['file']
Exception Type: KeyError at/mailman3/lists/ Exception Value: 'file' Request information: USER: AnonymousUser
-- Please let me know if you need further assistance.
Thank you for your business. We appreciate our clients. Brian Carpenter EMWD.com
-- EMWD's Knowledgebase: https://clientarea.emwd.com/index.php/knowledgebase
EMWD's Community Forums http://discourse.emwd.com/
On 4/21/20 1:10 PM, Brian Carpenter wrote:
Ok. The first thing however is did I miss a step?
Not really. The problem is FILTER_VHOST = True doesn't work for web hosts that aren't email hosts.
Here is the complete error that is sent to me via email as superuser:
Internal Server Error:/mailman3/lists/
KeyError at/mailman3/lists/ 'file'
Traceback:
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/postorius/views/list.py" in list_index 755. paginator_class=MailmanPaginator)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django_mailman3/lib/paginator.py" in paginate 71. objects = paginator.page(page_num)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django_mailman3/lib/paginator.py" in page 46. number = self.validate_number(number)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/paginator.py" in validate_number 48. if number > self.num_pages:
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/utils/functional.py" in __get__ 80. res = instance.__dict__[self.name] = self.func(instance)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/core/paginator.py" in num_pages 97. if self.count == 0 and not self.allow_empty_first_page:
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django/utils/functional.py" in __get__ 80. res = instance.__dict__[self.name] = self.func(instance)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/django_mailman3/lib/paginator.py" in count 56. return self.function(count=0, page=1).total_size
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/postorius/views/list.py" in _get_list_page 751. advertised=advertised, mail_host=mail_host, count=count, page=page)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailmanclient/client.py" in get_list_page 181. return Page(self._connection, url, MailingList, count, page)
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailmanclient/restbase/page.py" in __init__ 37. self._create_page()
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailmanclient/restbase/page.py" in _create_page 62. response, content = self._connection.call(self._build_url())
File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailmanclient/restbase/connection.py" in call 112. error_msg, response, None)
*During handling of the above exception (HTTP Error 404: {"title": "404 Not Found"}), another exception occurred:*
The above 404 is the underlying problem.
In the traceback above we see that /opt/mailman/mm/venv/lib/python3.7/site-packages/postorius/views/list.py at line 751 calls client to get the view for lists for this host.
The full code is
def _get_list_page(count, page): client = get_mailman_client() advertised = not request.user.is_superuser mail_host = request.get_host().split(":")[0] if ( getattr(settings, 'FILTER_VHOST', False)) else None return client.get_list_page( advertised=advertised, mail_host=mail_host, count=count, page=page)
The issue is the FILTER_VHOST = True setting is broken. This is <https://gitlab.com/mailman/postorius/-/issues/394>
The broken code tries to get the lists for the domain in the requesting URL which here is the web_host but the web_host has no lists.
This is a complicated issue. See the whole comment thread in the issue where I am trying to mentor someone to a fix, but he apparently has given up.
The issue is we don't have a method for retrieving lists by web host. It is simple enough to get all the email hosts associated with a web host, but what do we do if that's more than one email host.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 4/21/20 4:53 PM, Mark Sapiro wrote:
The issue is the FILTER_VHOST = True setting is broken.
Thanks Mark. I was wondering how this would turn out using the FILTER_VHOST setting. Unfortunately we have to have this setting turned on. Maybe I can get the client to agree to use the web domain as part of their list address.
Appreciate your help as always! Stay healthy.
-- Please let me know if you need further assistance.
Thank you for your business. We appreciate our clients. Brian Carpenter EMWD.com
-- EMWD's Knowledgebase: https://clientarea.emwd.com/index.php/knowledgebase
EMWD's Community Forums http://discourse.emwd.com/
Am 21.04.20 um 23:08 schrieb Brian Carpenter:
Maybe I can get the client to agree to use the web domain as part of their list address.
Hi,
maybe it is a solution for you what I did on my side (since it was already the setup for mailman2 my customer is happy with it):
Set everything up in mailman3 with lists.domain.com and define in postfix (if you use postfix, others should support it also) aliases from - let's say - list1@domain.com -> list1@lists.domain.com for each mail list.
In the list setup in mailman3 (available via postorius) define list1@domain.com as an allowed alias for list1@lists.domain.com
Best Torge
On 4/21/20 10:12 PM, Torge Riedel wrote:
Am 21.04.20 um 23:08 schrieb Brian Carpenter:
Maybe I can get the client to agree to use the web domain as part of their list address.
Hi,
maybe it is a solution for you what I did on my side (since it was already the setup for mailman2 my customer is happy with it):
Set everything up in mailman3 with lists.domain.com and define in postfix (if you use postfix, others should support it also) aliases from list.
- let's say - list1@domain.com -> list1@lists.domain.com for each mail
In the list setup in mailman3 (available via postorius) define list1@domain.com as an allowed alias for list1@lists.domain.com
This is a good workaround, however to be complete, you may also want MTA aliases for the list1-*@domain.com addresses.
Note, I'm currently working on a fix for <https://gitlab.com/mailman/postorius/-/issues/394>. Hopefully that will be in the next Postorius release.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (3)
-
Brian Carpenter
-
Mark Sapiro
-
Torge Riedel