PATCHing an Address without specifying a display name throws a 400 error.
I'm not sure of the exact scenario. I've seen this in two different contexts.
ERROR 2021-11-26 20:20:45,775 middleware 21272 140718758082368 Un-handled exception: HTTP Error 400: Missing Parameter: display_name
Traceback (most recent call last):
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/utils/decorators.py", line 45, in _wrapper
return bound_method(*args, **kwargs)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/allauth/account/views.py", line 138, in dispatch
return super(LoginView, self).dispatch(request, *args, **kwargs)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/allauth/account/views.py", line 81, in dispatch
**kwargs)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 97, in dispatch
return handler(request, *args, **kwargs)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/allauth/account/views.py", line 104, in post
response = self.form_valid(form)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/allauth/account/views.py", line 151, in form_valid
return form.login(self.request, redirect_url=success_url)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/allauth/account/forms.py", line 197, in login
redirect_url=redirect_url)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/allauth/account/utils.py", line 159, in perform_login
adapter.login(request, user)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/allauth/account/adapter.py", line 391, in login
django_login(request, user)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 132, in login
user_logged_in.send(sender=user.__class__, request=request, user=user)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in send
for receiver in self._live_receivers(sender)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in <listcomp>
for receiver in self._live_receivers(sender)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/contrib/auth/models.py", line 20, in update_last_login
user.save(update_fields=['last_login'])
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 66, in save
super().save(*args, **kwargs)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/db/models/base.py", line 741, in save
force_update=force_update, update_fields=update_fields)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/db/models/base.py", line 790, in save_base
update_fields=update_fields, raw=raw, using=using,
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in send
for receiver in self._live_receivers(sender)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in <listcomp>
for receiver in self._live_receivers(sender)
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/django_mailman3/signals.py", line 102, in create_profile
address.save()
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/mailmanclient/restbase/base.py", line 110, in save
self._url, self._changed_rest_data, method='PATCH')
File "/opt/mailman/mm/venv/lib/python3.6/site-packages/mailmanclient/restbase/connection.py", line 167, in call
error_msg, response, None)
urllib.error.HTTPError: HTTP Error 400: Missing Parameter: display_name
This resulted from the following sequence:
2600:1700:b2d2:a6f:c11b:d5c9:7e9:cec3 - - [26/Nov/2021:15:20:35 -0500] "GET /mailman3/lists/python-buildbots.python.org/held_messages HTTP/1.1" 302 5711 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
2600:1700:b2d2:a6f:c11b:d5c9:7e9:cec3 - - [26/Nov/2021:15:20:35 -0500] "GET /accounts/login/?next=/mailman3/lists/python-buildbots.python.org/held_messages HTTP/1.1" 200 3624 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
2600:1700:b2d2:a6f:c11b:d5c9:7e9:cec3 - - [26/Nov/2021:15:20:45 -0500] "POST /accounts/login/ HTTP/1.1" 400 6502 "https://mail.python.org/accounts/login/?next=/mailman3/lists/python-buildbots.python.org/held_messages" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
A similar error is discussed in the comment thread at django-mailman3#51 (closed). In both cases, we get to create_profile
in django_mailman3/signals.py which is trying to update the display name in the user's addresses. I think in both cases the user has multiple address records which is probably significant.
In any case, we ultimately get to the save
method in mailmanclient/restbase/base.py, but for at least one of the addresses we are trying to set the display_name
to the already existing value so that self._changed_rest_data
is an empty dictionary so there is no display_name
and the AnAddress.on_patch
method in mailman/rest/addresses.py returns the 400 error.
I'm not sure of the best approach, but perhaps just ignoring the missing display_name
when PATCHing an Address
is the way to go.