Hi gang,
I probably have already developed an uneviable reputation of being able to produce the finest of mess. I stay true to form here.
In my 3.12 installation when my admin clicks to view the held messages, he gets an internal server error. The error comes from postorius, where the log entry is
2026-04-15 12:45:25 [FALCON] [ERROR] GET /3.1/lists/bibnez@folks.email/held => Traceback (most recent call last): File "falcon/app.py", line 440, in falcon.app.App.__call__ File "/usr/local/mailman/venv/lib/python3.12/site-packages/mailman/rest/post_moderation.py", line 194, in on_get resource = self._make_collection(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/mailman/venv/lib/python3.12/site-packages/mailman/rest/helpers.py", line 189, in _make_collection [etag(resource) for resource in entries] ^^^^^^^^^^^^^^ File "/usr/local/mailman/venv/lib/python3.12/site-packages/mailman/rest/helpers.py", line 104, in etag return json.dumps(resource, cls=ExtendedEncoder, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/json/__init__.py", line 238, in dumps **kw).encode(obj) ^^^^^^^^^^^ File "/usr/lib/python3.12/json/encoder.py", line 200, in encode chunks = self.iterencode(o, _one_shot=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/json/encoder.py", line 258, in iterencode return _iterencode(o, 0) ^^^^^^^^^^^^^^^^^ File "/usr/local/mailman/venv/lib/python3.12/site-packages/mailman/rest/helpers.py", line 68, in default return super().default(obj) ^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/json/encoder.py", line 180, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type set is not JSON serializable
Checking the actual set that is returned, by converting the set into a string and writing it to a file (by enhancing helpers.py), I discover that what is returned is as set of 53 email addresses, not of 24 messages as the web interface suggests.
Intrestingly, my admin reports that the he is correctly informed about the held messages via email. The then forwards those that need posting to the list.
I suspect that to get to the bottom of this problem, I need to use the low-level postorious functions that actually access the parse the held message data.
-- Written by Thomas Krichel http://openlib.org/home/krichel on his 22230th day.
Thomas Krichel writes:
File "/usr/lib/python3.12/json/encoder.py", line 180, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type set is not JSON serializable
This appears to be related to https://gitlab.com/mailman/mailman/-/work_items/668. There's a patch at the end that may help. I can't promise it will. But I have assigned the issue to myself for later followup.
I suspect that to get to the bottom of this problem, I need to use the low-level postorious functions that actually access the parse the held message data.
No, I think you want to make sure that the REST API doesn't pass a set to the JSON encoder. I suppose that there are a bunch of "things" there that might be "the same", and the developer who wrote the code wanted to compress the representation a bit. But they didn't realize that sets won't be serialized by the stdlib json module. I doubt very much that Postorius cares: it probably just treats that object as a sequence.
I don't understand why sets (like tuples and lists) don't just encode to JSON sequences, and let the deserializer decide which model is best for the container, but that's life, I guess.
Regards, Steve
-- GNU Mailman consultant (installation, migration, customization) Sirius Open Source https://www.siriusopensource.com/ Software systems consulting in Europe, North America, and Japan
participants (2)
-
Stephen J. Turnbull -
Thomas Krichel