`TypeError: Population must be a sequence. For dicts or sets, use sorted(d).` when attempting to play favorites radio
Steps to reproduce
- Visit the page at /favorites
- Click Play radio
What happens?
No radio started, 500 error in browser console, this error from funkwhale server:
May 30 16:50:20 machine gunicorn[3469894]: 2023-05-30 23:50:20,359 django.request ERROR Internal Server Error: /api/v1/radios/tracks/
May 30 16:50:20 machine gunicorn[3469894]: Traceback (most recent call last):
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/virtualenv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 47, in inner
May 30 16:50:20 machine gunicorn[3469894]: response = get_response(request)
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/virtualenv/lib/python3.11/site-packages/django/core/handlers/base.py", line 181, in _get_response
May 30 16:50:20 machine gunicorn[3469894]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/lib/python3.11/contextlib.py", line 81, in inner
May 30 16:50:20 machine gunicorn[3469894]: return func(*args, **kwds)
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/virtualenv/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
May 30 16:50:20 machine gunicorn[3469894]: return view_func(*args, **kwargs)
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/virtualenv/lib/python3.11/site-packages/rest_framework/viewsets.py", line 125, in view
May 30 16:50:20 machine gunicorn[3469894]: return self.dispatch(request, *args, **kwargs)
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/virtualenv/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
May 30 16:50:20 machine gunicorn[3469894]: response = self.handle_exception(exc)
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/virtualenv/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
May 30 16:50:20 machine gunicorn[3469894]: self.raise_uncaught_exception(exc)
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/virtualenv/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
May 30 16:50:20 machine gunicorn[3469894]: raise exc
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/virtualenv/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
May 30 16:50:20 machine gunicorn[3469894]: response = handler(request, *args, **kwargs)
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/api/funkwhale_api/radios/views.py", line 141, in create
May 30 16:50:20 machine gunicorn[3469894]: session.radio.pick()
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/api/funkwhale_api/radios/radios.py", line 89, in pick
May 30 16:50:20 machine gunicorn[3469894]: return self.pick_many(quantity=1, **kwargs)[0]
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/api/funkwhale_api/radios/radios.py", line 93, in pick_many
May 30 16:50:20 machine gunicorn[3469894]: picked_choices = super().pick_many(choices=choices, quantity=quantity)
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/share/webapps/funkwhale/api/funkwhale_api/radios/radios.py", line 29, in pick_many
May 30 16:50:20 machine gunicorn[3469894]: return random.sample(set(choices), quantity)
May 30 16:50:20 machine gunicorn[3469894]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 30 16:50:20 machine gunicorn[3469894]: File "/usr/lib/python3.11/random.py", line 439, in sample
May 30 16:50:20 machine gunicorn[3469894]: raise TypeError("Population must be a sequence. "
May 30 16:50:20 machine gunicorn[3469894]: TypeError: Population must be a sequence. For dicts or sets, use sorted(d).
What is expected?
Radio starts playing favorites, no errors
Context
Funkwhale version(s) affected: 1.2.10
Browser: Firefox 113.0.2
OS: Arch Linux (for browser and server)
Python version: 3.11.3