invalid parameter response of the rest-api
Hello,
Since a few days we get an error response from our automated membership script.
We use the following code to control the membership for some lists:
def mailinglist_manage(list_address, members):
"""
make sure all 'members' are present on the list and no remove
everyone else
list_address : mail address of mailing list to manage
addresses : mail address that are supposed to be on the list
"""
print("[*] update subscriptions for {}".format(list_address))
ml = mmc.get_list(list_address)
# make sure we dont spam users
ml.settings['send_welcome_message'] = False
ml.settings.save()
addresses = set(members.keys())
ml_members = ml.members
ml_addresses = set((x.address.__str__() for x in ml_members))
for addr in ml_addresses - addresses:
print("unsubscribe {} from {}".format(addr, list_address))
ml.unsubscribe(addr)
for addr in addresses - ml_addresses:
print("subscribe {} to {}".format(addr, list_address))
ml.subscribe(addr, members[addr],
pre_verified=True, pre_confirmed=True,
pre_approved=True)
Since Tuesday without any update performed by us we get the following error from the script when it's running:
Traceback (most recent call last):
File "./mail_user_control.py", line 423, in <module>
mailinglist_manage("XXX@EXAMPLE.COM", members)
File "./mail_user_control.py", line 412, in mailinglist_manage
pre_verified=True, pre_confirmed=True, pre_approved=True)
File
"/root/.local/lib/python3.6/site-packages/mailmanclient/restobjects/mailinglist.py",
line 339, in subscribe
response, content = self._connection.call('members', data)
File
"/root/.local/lib/python3.6/site-packages/mailmanclient/restbase/connection.py",
line 112, in call
error_msg, response, None)
urllib.error.HTTPError: HTTP Error 400: Invalid Parameter "subscriber":
.
If you have an idea why that code now returns this. I would be thankful.
regards
Jacob Sievert
Dear Jacob did you make any progress on this issue? I've exactly the same problem....
gioklr71@gmail.com writes:
Dear Jacob did you make any progress on this issue? I've exactly the same problem....
Is Jacob's problem really exactly the same as yours? Please compare your error message to Jacob's: https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/...
Jacob Sievert writes:
Since a few days we get an error response from our automated membership script.
We use the following code to control the membership for some lists:
def mailinglist_manage(list_address, members):
This looks like it should work.
Since Tuesday without any update performed by us we get the following error from the script when it's running:
*Something* changed. It would likely help if one of you can figure out what.
line 339, in subscribe response, content = self._connection.call('members', data) File "/root/.local/lib/python3.6/site-packages/mailmanclient/restbase/connection.py",
Either mailmanclient is now marshalling the URL and data incorrectly (which is hard to believe, it's hard to imagine this simple call is causing an error without causing both Postorius and HyperKitty to break too), or the REST protocol has changed for that resource, and the resource accessed by the URL that is constructed by self._connection.call() is not the member roster. This also seems unlikely.
Your installation seems very old. From the next version of Mailman, we will not target Python 3.6 (that is, we have dropped it from the automated test pipeline), so regressions may occur. I know of at least one that occurs in old versions of core if you upgrade Python from < 3.8 to >= 3.8. Your Mailman installation also seems quite old: the code that the frame above says is on line 339 is on line 491 in git head.
Are you sure you haven't applied a batch of security updates or the like that might affect any of Python, mailmanclient, or Mailman core?
This is the code that produce the error:
for mail, nom in email_D.items(): # Loop over new email
print(info.subscribe(mail, nom, pre_verified=True, pre_confirmed=True, send_welcome_message=False, pre_approved=True))
THIS IS THE ERROR MESSAGGE:
Traceback (most recent call last): File "./fill_list.py", line 74, in <module> print(info.subscribe(mail, nom, pre_verified=True, pre_confirmed=True, send_welcome_message=False, pre_approved=True)) File "/usr/local/lib/python3.6/site-packages/mailmanclient/restobjects/mailinglist.py", line 492, in subscribe response, content = self._connection.call('members', data) File "/usr/local/lib/python3.6/site-packages/mailmanclient/restbase/connection.py", line 161, in call error_msg, response, None) urllib.error.HTTPError: HTTP Error 400: Invalid Parameter "subscriber": .
This code works perfectly before security update from provider.... Never changed from client side.
I've tried update mailman client:
pip3.6 install --upgrade mailmanclient Requirement already satisfied: mailmanclient in /usr/local/lib/python3.6/site-packages (3.3.3) Requirement already satisfied: requests in /usr/local/lib/python3.6/site-packages (from mailmanclient) (2.27.1) Requirement already satisfied: typing_extensions in /usr/local/lib/python3.6/site-packages (from mailmanclient) (4.1.1) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests->mailmanclient) (2021.10.8) Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.6/site-packages (from requests->mailmanclient) (2.0.12) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests->mailmanclient) (1.26.8) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests->mailmanclient) (3.3)
On 9/21/22 14:12, gioklr71@gmail.com wrote:
This is the code that produce the error:
for mail, nom in email_D.items(): # Loop over new email print(info.subscribe(mail, nom, pre_verified=True, pre_confirmed=True, send_welcome_message=False, pre_approved=True))
THIS IS THE ERROR MESSAGGE:
Traceback (most recent call last): File "./fill_list.py", line 74, in <module> print(info.subscribe(mail, nom, pre_verified=True, pre_confirmed=True, send_welcome_message=False, pre_approved=True)) File "/usr/local/lib/python3.6/site-packages/mailmanclient/restobjects/mailinglist.py", line 492, in subscribe response, content = self._connection.call('members', data) File "/usr/local/lib/python3.6/site-packages/mailmanclient/restbase/connection.py", line 161, in call error_msg, response, None) urllib.error.HTTPError: HTTP Error 400: Invalid Parameter "subscriber": .
This code works perfectly before security update from provider.... Never changed from client side.
I've tried update mailman client:
Mailman client is not the issue. The issue is the REST endpoint
'members' doesn't like the value of subscriber
in the post data. In
particular, it looks like you have an entry in email_D.items()
with an
empty value for mail
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Hi Mark. I put a print_dict(email_D) and ALL records are email; (name surname) and no empty values are present. To be sure I've modified code...
for mail, nom in email_D.items(): # Loop over Dictionary items (Email, Name) if (mail) and (nom): print(info.subscribe(mail, nom, pre_verified=True, pre_confirmed=True, send_welcome_message=False, pre_approved=True))
Same error. I tried also with Python 3.8 and last mailmanclient version: /usr/local/bin/pip3.8 freeze | grep mailman mailman==3.3.5 mailmanclient==3.3.3
Always the same error: Traceback (most recent call last): File "./fill_list.py", line 75, in <module> print(info.subscribe(mail, nom, pre_verified=True, pre_confirmed=True, send_welcome_message=False, pre_approved=True)) File "/home/sciadmin/.local/lib/python3.8/site-packages/mailmanclient/restobjects/mailinglist.py", line 492, in subscribe response, content = self._connection.call('members', data) File "/home/sciadmin/.local/lib/python3.8/site-packages/mailmanclient/restbase/connection.py", line 160, in call raise HTTPError(params.get('url'), response.status_code, urllib.error.HTTPError: HTTP Error 400: Invalid Parameter "subscriber": .
On 9/21/22 16:14, gioklr71@gmail.com wrote:
Hi Mark. I put a print_dict(email_D) and ALL records are email; (name surname) and no empty values are present. To be sure I've modified code...
for mail, nom in email_D.items(): # Loop over Dictionary items (Email, Name) if (mail) and (nom): print(info.subscribe(mail, nom, pre_verified=True, pre_confirmed=True, send_welcome_message=False, pre_approved=True))
What are actually passing. mail may not be empty, but it is not a valid email address as checked by https://gitlab.com/mailman/mailman/-/blob/master/src/mailman/email/validate....
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Hi Mark, in the end you were right! I printed the dictionary items (email, name) and entered them via Postorius and found a wrong address. After correcting the address the APIs worked. Let's say that the reporting of the wrong email format in the code is not very clear .... In any case, problem solved. Thank you very much for your time!
Gianni
participants (4)
-
gioklr71@gmail.com
-
Jacob Sievert
-
Mark Sapiro
-
Stephen J. Turnbull