MAM request: NoneType error when using "with_"
I'm using nbxmpp to build an XMPP client and I'm facing an issue when making a MAM request.
Versions:
- nbxmpp: 6.1.1
- PyGObject: 3.52.3
When the MAM request parameter with_
is None
, the request succeeds. But when with_
is anything else (the JID of a chat as an str
, or a random, invalid str
), this error occurs:
ERROR:nbxmpp.m.mam:(140156916014336) Fatal Exception
Traceback (most recent call last):
File "[...]/nbxmpp/task.py", line 223, in _next_step
res = self._gen.send(result)
^^^^^^^^^^^^^^^^^^^^^^
File "[...]/nbxmpp/modules/mam.py", line 53, in make_query
response = yield _make_request(jid, queryid, start, end, with_, after, max_)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[...]/nbxmpp/modules/mam.py", line 165, in _make_request
payload = [_make_query_form(start, end, with_), _make_rsm_query(max_, after)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[...]/nbxmpp/modules/mam.py", line 138, in _make_query_form
fields.append(create_field(typ="jid-single", var="with", value=with_))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[...]/nbxmpp/modules/dataforms.py", line 66, in create_field
field: FieldT = {
^
File "[...]/nbxmpp/modules/dataforms.py", line 146, in __init__
self.options = options
^^^^^^^^^^^^
File "[...]/nbxmpp/modules/dataforms.py", line 404, in options
for value, label in values:
TypeError: 'NoneType' object is not iterable
I'm only using the jid
, queryid
, with_
and callback
request parameters.
This is where the error occurs:
@options.setter
def options(self, values: list[tuple[Any, str]]) -> None:
del self.options
for value, label in values: # <-- Here!
self.addChild("option", {"label": label}).setTagData("value", value)
I changed the method to this as an experiment:
@options.setter
def options(self, values: list[tuple[Any, str]] | None) -> None:
del self.options
if values is None:
return
for value, label in values:
self.addChild("option", {"label": label}).setTagData("value", value)
Then, it doesn't fail, but with_
seems to be ignored.