Fatal Track exceptions
Closed this issue · 3 comments
Description
When running the latest version of the Jukebox, i.e. mkIII-1.0.1, two errors happen for the same reason. Just loading the main page right after the server started generates the following:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/python3/dist-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/hackademint/jukebox-ultra-nrv/jukebox/src/playlist.py", line 78, in suggest
track = Track.get_random_track(app.config["DATABASE_PATH"])
File "/home/hackademint/jukebox-ultra-nrv/jukebox/src/Track.py", line 134, in get_random_track
source=r[7], blacklisted=r[8], obsolete=r[9])
IndexError: tuple index out of range
I investigated a bit, and by displaying the request result in Track.get_random_track(), it gives this for example: (481, 'http://www.youtube.com/watch?v=CkbZg6M4kjE', 'Tryo - La main verte (Live) (Audio)', 'TryoVEVO', '', 135, 'https://i.ytimg.com/vi/CkbZg6M4kjE/mqdefault.jpg', 'youtube', 0)
, which only contains nine elements and not ten as expected in the method. I'm guessing there were some changes in the jukebox database because when displaying the schema, the track_info table looks like this:
CREATE TABLE IF NOT EXISTS "track_info" (
"id" INTEGER PRIMARY KEY,
"url" TEXT NOT NULL,
"track" TEXT,
"artist" TEXT,
"album" TEXT,
"duration" INT,
"albumart_url" TEXT,
"source" TEXT,
"blacklisted" BOOLEAN DEFAULT 0
);
but in Track.get_random_track(), obsolete=r[9]
is given as an optional argument of the Track constructor. It seems to me that is was forgotten from a previous version, but I can't really tell which, because I haven't looked into it for a few months. So then I removed the obsolete=r[9]
parameter and that last part seems to work fine.
But when adding a track in the jukebox, another error pops:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/python3/dist-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/hackademint/jukebox-ultra-nrv/jukebox/src/util.py", line 14, in decorated
return f(*args, **kwargs)
File "/home/hackademint/jukebox-ultra-nrv/jukebox/src/playlist.py", line 26, in add
track = Track.import_from_url(app.config["DATABASE_PATH"], track_dict["url"])
File "/home/hackademint/jukebox-ultra-nrv/jukebox/src/Track.py", line 116, in import_from_url
albumart_url=r[6], source=r[7], blacklisted=r[8], obsolete=r[9])
IndexError: tuple index out of range
This time, it is in Track.import_from_url(), but it is for the same reason, so I fixed it the same way, by removing the missing parameter. Then, everything seemed to work fine. I also made the fix in Track.import_from_id() just in case.
Version of the jukebox: mkIII-1.0.1, commit 3852d5b
Environment:
- OS: Linux 5.2.0-kali3-amd64 #1 SMP Debian 5.2.17-1kali1 (2019-09-27) x86_64 GNU/Linux, so it's a Debian-like.
- Python: 3.7.5rc1
When talking about this with someone else, we also thought that it might be caused by an update that brought a new attribute in the track_info table, but that our database was not regenerated accordingly. If it is the case, please tell us how to fix the database in order to be compatible with the latest version. Also, another club uses this version and apparently had no problem whatsoever, so maybe it is linked to the database issue.
I investigated a bit more around the database because other errors were generated and yes, the problem was that you added an obsolete
boolean attribute to the track_info
table schema, but it was not taken into account in the already existing database. So then I altered the table to add the column and it seems to work fine now. In future releases, maybe you should consider distributing patches to add / alter / remove the concerned things.
Yeah, I added the obsolete attribute in version 1.0.0, and as I haven't made any script to migrate from versions, I have only wrote the alteration to run in the changelog (https://github.com/matthias4217/jukebox-ultra-nrv/releases/tag/mkIII-1.0.0).
In the future, if any more breaking changes are made, I'll work on a system to prevent such issues. Thank you for your mention anyway !
Yeah, I added the obsolete attribute in version 1.0.0, and as I haven't made any script to migrate from versions, I have only wrote the alteration to run in the changelog (https://github.com/matthias4217/jukebox-ultra-nrv/releases/tag/mkIII-1.0.0).
In the future, if any more breaking changes are made, I'll work on a system to prevent such issues. Thank you for your mention anyway !
Alright, so it was as we thought. Thanks anyway.