'str' object has no attribute 'token_type'
Hi everybody,
I'm sorry for being always the strange guy with strange errors here but for some reason... I am. On a Mailman installation that was doing just fine for more than a year, I started receiving error messages per email. It happens when mailman daemon archives a messages. Although the messages is correctly archived, this exception is thrown by Hyperkitty:
Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.9/dist-packages/django/views/decorators/http.py", line 40, in inner return func(request, *args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/hyperkitty/views/mailman.py", line 118, in _decorator return func(request, *args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/hyperkitty/views/mailman.py", line 164, in archive add_to_list(mlist_fqdn, msg) File "/usr/local/lib/python3.9/dist-packages/hyperkitty/lib/incoming.py", line 79, in add_to_list from_str = header_to_unicode(message['From']) File "/usr/lib/python3.9/email/message.py", line 391, in __getitem__ the values matching a header field name. File "/usr/lib/python3.9/email/message.py", line 471, in get for k, v in self._headers: File "/usr/lib/python3.9/email/policy.py", line 163, in header_fetch_parse return self.header_factory(name, value) File "/usr/lib/python3.9/email/headerregistry.py", line 601, in __call__ return self[name](name, value) File "/usr/lib/python3.9/email/headerregistry.py", line 196, in __new__ cls.parse(value, kwds) File "/usr/lib/python3.9/email/headerregistry.py", line 343, in parse [Address(mb.display_name or '', File "/usr/lib/python3.9/email/headerregistry.py", line 343, in <listcomp> [Address(mb.display_name or '', File "/usr/lib/python3.9/email/_header_value_parser.py", line 462, in display_name return self[0].display_name File "/usr/lib/python3.9/email/_header_value_parser.py", line 393, in display_name return self[0].display_name File "/usr/lib/python3.9/email/_header_value_parser.py", line 574, in display_name if res[-1][-1].token_type == 'cfws':
Exception Type: AttributeError at /hyperkitty/api/mailman/archive Exception Value: 'str' object has no attribute 'token_type' Request information: USER: AnonymousUser
I upgraded both to Debian 11 (from 10) and to latest versions of Hyperkitty, mailman-hyperkitty and mailman but still getting the error. Other installations with same specs I'm managing to do not encounter this problem. Any clue of what could have happened, why and how to fix it?
Thanks in advance, Marco
On 11/15/21 6:06 AM, Marco Marinello wrote:
Hi everybody,
I'm sorry for being always the strange guy with strange errors here but for some reason... I am. On a Mailman installation that was doing just fine for more than a year, I started receiving error messages per email. It happens when mailman daemon archives a messages. Although the messages is correctly archived, this exception is thrown by Hyperkitty:
Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.9/dist-packages/django/views/decorators/http.py", line 40, in inner return func(request, *args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/hyperkitty/views/mailman.py", line 118, in _decorator return func(request, *args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/hyperkitty/views/mailman.py", line 164, in archive add_to_list(mlist_fqdn, msg) File "/usr/local/lib/python3.9/dist-packages/hyperkitty/lib/incoming.py", line 79, in add_to_list from_str = header_to_unicode(message['From']) File "/usr/lib/python3.9/email/message.py", line 391, in __getitem__ the values matching a header field name. File "/usr/lib/python3.9/email/message.py", line 471, in get for k, v in self._headers: File "/usr/lib/python3.9/email/policy.py", line 163, in header_fetch_parse return self.header_factory(name, value) File "/usr/lib/python3.9/email/headerregistry.py", line 601, in __call__ return self[name](name, value) File "/usr/lib/python3.9/email/headerregistry.py", line 196, in __new__ cls.parse(value, kwds) File "/usr/lib/python3.9/email/headerregistry.py", line 343, in parse [Address(mb.display_name or '', File "/usr/lib/python3.9/email/headerregistry.py", line 343, in <listcomp> [Address(mb.display_name or '', File "/usr/lib/python3.9/email/_header_value_parser.py", line 462, in display_name return self[0].display_name File "/usr/lib/python3.9/email/_header_value_parser.py", line 393, in display_name return self[0].display_name File "/usr/lib/python3.9/email/_header_value_parser.py", line 574, in display_name if res[-1][-1].token_type == 'cfws':
Exception Type: AttributeError at /hyperkitty/api/mailman/archive Exception Value: 'str' object has no attribute 'token_type' Request information: USER: AnonymousUser
I upgraded both to Debian 11 (from 10) and to latest versions of Hyperkitty, mailman-hyperkitty and mailman but still getting the error. Other installations with same specs I'm managing to do not encounter this problem. Any clue of what could have happened, why and how to fix it?
The exception is thrown in the Python email package on HyperKitty's attempt to get the From: header of the message. This looks like https://bugs.python.org/issue43501 and/or https://bugs.python.org/issue30988. These issues refer to display names beginning or ending with a dot. Is that the case with the From: header of the problem messages?
Note that display names containing dot should be quoted.
It appears that at least one of the people posting posts with the problem From: header.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
Marco Marinello
-
Mark Sapiro