Handle the case when a User is subscribed with more than one address
The code seems to make an assumption that a single address can be subscribed to a list with only one membership. This is not true in case when a user is subscribed as user and subscribed with primary address as address.
This is a traceback from local test env.
[2021-02-14 13:37:07 -0800] [99435] [ERROR] Error handling request /3.1/lists/mylist.lists.araj.me/member/maxking123%40araj.me
Traceback (most recent call last):
File "/home/maxking/.virtualenvs/py3/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 3490, in one
ret = self.one_or_none()
File "/home/maxking/.virtualenvs/py3/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 3467, in one_or_none
raise orm_exc.MultipleResultsFound(
sqlalchemy.orm.exc.MultipleResultsFound: Multiple rows were found for one_or_none()
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/maxking/Documents/mm3/core-2/src/mailman/model/subscriptions.py", line 136, in find_member
return (result if result is None else result.one())
File "/home/maxking/.virtualenvs/py3/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 3492, in one
util.raise_(
File "/home/maxking/.virtualenvs/py3/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
raise exception
sqlalchemy.orm.exc.MultipleResultsFound: Multiple rows were found for one()
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/maxking/.virtualenvs/py3/lib/python3.9/site-packages/gunicorn/workers/sync.py", line 134, in handle
self.handle_request(listener, req, client, addr)
File "/home/maxking/.virtualenvs/py3/lib/python3.9/site-packages/gunicorn/workers/sync.py", line 175, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/home/maxking/Documents/mm3/core-2/src/mailman/database/transaction.py", line 50, in wrapper
rtn = function(*args, **kws)
File "/home/maxking/Documents/mm3/core-2/src/mailman/rest/wsgiapp.py", line 193, in __call__
return super().__call__(environ, start_response)
File "/home/maxking/.virtualenvs/py3/lib/python3.9/site-packages/falcon/api.py", line 249, in __call__
responder, params, resource, req.uri_template = self._get_responder(req)
File "/home/maxking/.virtualenvs/py3/lib/python3.9/site-packages/falcon/api.py", line 681, in _get_responder
route = self._router_search(path, req=req)
File "/home/maxking/Documents/mm3/core-2/src/mailman/rest/wsgiapp.py", line 140, in find
result = attribute(
File "/home/maxking/Documents/mm3/core-2/src/mailman/rest/lists.py", line 213, in member
member = getUtility(ISubscriptionService).find_member(
File "/home/maxking/Documents/mm3/core-2/src/mailman/model/subscriptions.py", line 143, in find_member
raise TooManyMembersError(subscriber, list_id, role)
mailman.interfaces.subscriptions.TooManyMembersError
[14/Feb/2021:13:37:07 -0800] "GET /3.1/lists/mylist.lists.araj.me/member/maxking123%40araj.me HTTP/1.1" 500 0 "-" "-"