Scrobbler plugin failing to reset invalid auth sessions for last.fm
Steps to reproduce
- Go to funkwhale's account settings -> Manage plugins
- Enable and connect a last.fm scrobbler the normal way.
- Go to your last.fm account -> Settings -> Applications.
- Disconnect the Funkwhale application.
- Attempt to reconnect your last.fm to funkwhale again.
What happens?
Nothing happens, track listens do not get logged on last.fm (they still do in Funkwhale itself), the app does not connect back to your last.fm account
What is expected?
Funkwhale app is expected to connect back to your last.fm account and keep on logging track listens.
Context & Possible Fix
I stumbled upon this bug when I accidentally disconnected my Funkwhale scrobbler from my last.fm account. Upon trying to rerun the scrobbler plugin setup it wouldn't work at all.
journalctl -u funkwhale-server
has given me the following:
-- Logs begin at Tue 2022-04-12 17:57:52 UTC, end at Sat 2023-10-07 12:56:39 UTC. --
Oct 07 12:35:29 funkwhalemiv2nir gunicorn[1208]: 2023-10-07 12:35:29,946 plugins WARNING Plugin scrobbler errored during hook listening_created: <?xml version="1.0" encoding="UTF-8"?>
Oct 07 12:35:29 funkwhalemiv2nir gunicorn[1208]: <lfm status="failed">
Oct 07 12:35:29 funkwhalemiv2nir gunicorn[1208]: <error code="9">Invalid session key - Please re-authenticate</error>
Oct 07 12:35:29 funkwhalemiv2nir gunicorn[1208]: </lfm>
It seems like Funkwhale was using the expired session that has been saved in the system to authenticate with last.fm and failing repeatedly.
Upon further digging I figured out where those sessions are stored and typed in the following into funkwhale's shell:
- from django.core.cache import caches
- cache.keys('scrobbler*')
- cache.delete(<insert retrieved keys here>)
Upon doing so the last.fm session stored in Funkwhale has been reset, allowing for a new one to properly generate and so my scrobbling has been restored. I suppose doing this automatically or providing users an option to do so could be a solution to this issue.
Funkwhale version(s) affected: 1.2.9