Scanner update path silently drops contributor_track for tag-less files; 'status' with artist tags then skips the track
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start in Slim/Schema.pm at _createContributorRoleRelationships and _mergeAndCreateContributors to see how the update path (via updateOrCreateBase → _postCheckAttributes) drops contributor_track rows for tag-less files. Also inspect Queries.pm statusQuery and Slim/Schema.pm _getTagDataForTracks. Reproduce with a tag-less MP3 scan, then verify contributor_track gains a NO_ARTIST row or status returns the playing track in playlist_loop.
Written by the indexing model from the issue text.
Description
Describe the bug
When an audio file without any tags (no TPE1/TIT2 — common with old, loose-download MP3s) is picked up by the "changed" scan path, the track ends up with primary_artist set (to the NO_ARTIST singleton, e.g. "Unknown Artist" / "Kein Interpret") but zero contributor_track rows.
Afterwards, status queries that request artist tags silently skip the track, with visible consequences for clients:
status <player> - 1 tags:alygdue(current track) returns an emptyplaylist_loopwhile that track is playing,status <player> 2 tags:aAlyjegdKNureturns aplaylist_loopstarting at the next track, so a now-playing display shows the wrong (next) song while the current one plays.
To reproduce
- Library with an MP3 that has no ID3 tags (e.g.
Audio::Scanreports onlyPRIV/TCON, noTIT2/TPE1), already in the DB. - Touch the file (or create a mtime/size mismatch) so the scanner classifies it as "changed".
- Observe in
library.db:
SELECT id, primary_artist FROM tracks WHERE url = '...'; -- primary_artist set (NO_ARTIST id)
SELECT * FROM contributor_track WHERE track = <that id>; -- 0 rows
- Play the track and query the player:
status <player> - 1 tags:alygdue -> playlist_loop: []
status <player> 2 tags:aAlyjegdKNu -> playlist_loop starts at next index (wrong current song)
Expected behavior
Either the update path keeps a NO_ARTIST contributor_track row (like the create path does), or the tag-data query does not silently drop tracks (Queries.pm statusQuery has next if !$data;).
Root cause (analysis of 9.1.1 code)
Slim::Schema::_createContributorRoleRelationshipsdeletes allcontributor_trackrows for the track, then re-inserts from the freshly read tag set.Slim::Schema::_mergeAndCreateContributorsonly creates the NO_ARTIST fallback contributorif ($create && !$foundContributor).- The update path (
updateOrCreateBase→_postCheckAttributeswithcreate => 0) therefore re-inserts nothing for a tag-less file, whileprimary_artistretains its stale value (on creation the same file correctly getsprimary_artist = NO_ARTISTplus a matchingcontributor_trackrow). Slim::Schema::_getTagDataForTracksjoinscontributor_track((contributors.id = tracks.primary_artist OR tracks.primary_artist IS NULL)when queried by trackIds); a track with no rows produces no result, andQueries.pm statusQuerydoesnext if !$data;— the track vanishes fromplaylist_loopwithout any log message.
We found 8 such tracks in a ~88k track library; nightly "changed audio files" scans had silently broken them one after another. Reproduced deterministically with a silent squeezelite instance: while the tag-less track plays, status 1 with artist tags returns an empty loop, status 2 returns the next track as "current".
Additional context
A second effect of the same re-read churn: because tracks.url is COLLATE NOCASE (bug 17457), case-insensitive duplicate files on disk (e.g. Song.mp3 with tags + song.mp3 without tags) both match the same DB row, keeping it permanently "changed" and re-breaking it on every nightly scan. This may explain some "rescan seems unreliable" reports (e.g. #977).
Workaround we applied
Write TPE1/TIT2 into the affected tag-less files; the next scan restores correct contributor_track rows. A client-side fallback (re-query without artist tags when playlist_loop is unexpectedly empty/short) can mask the display bug but not the history/statistics loss.
LMS 9.1.1 (Debian package), Perl 5.36, library on btrfs.
- Dominant language
- Perl
- Stars
- 1.8k
- Forks
- 386
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 14
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LMS-Community/slimserver
-
Sync playback crashes repeatedly in a sync group (v9.1.1)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LMS-Community/slimserver#1701 · 6 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
LMS-Community/slimserver#1555 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
LMS-Community/slimserver#1710 · 2 comments ·
Maintainers usually reply within 1 day
-
Windows: DST timestamp "fix" (bug 18078) marks ~90% of library as changed after every clock change; freezes server when triggered by a folder browsePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
LMS-Community/slimserver#1707 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
LMS-Community/slimserver#1683 · 3 comments ·
Maintainers usually reply within 1 day
All issues in LMS-Community/slimserver
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
RotherOSS/otobo#6344 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
darold/pgFormatter#426 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 77/100
libwww-perl/URI#219 ·
-
First suggestions when editing an existing tag does not use the existing textPossibly taken @AdityaOP007 claimed this today. Open✏️ Editing - Tags
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
openfoodfacts/openfoodfacts-server#15127 · 2 comments ·
Maintainers usually reply within 1 day