fix(bandcamp_importer): namespace label cache key on discography pages#930
fix(bandcamp_importer): namespace label cache key on discography pages#930chaban-mb wants to merge 1 commit into
Conversation
… MBID collision On discography/band pages, the label lookup used the bare URL as the cache key (e.g. 'https://example.bandcamp.com'). This is the same key the artist lookup uses. When a label was found, its MBID was cached under the bare URL. On subsequent album page visits, resolveMBID(root_url) would find that label MBID and incorrectly seed it as the release artist credit, causing MusicBrainz to reject the import with 'Invalid artist_credit.names.0.mbid'. The fix adds a 'label:' prefix to the cache key, matching the pattern already used on album pages (line 610). Closes murdos#795
|
I suspect that it is the same problem that leads to #797. Could you verify that this fix also resolves that problem?
Also, do you think it makes sense to prefix artist lookups as well, so there's never an ambiguity? |
Inserts a label link for me there. But this won't fix existing cache. That would require waiting for it to expire, manually clearing or bumping cache key version. Also when a Bandcamp page is linked to both an artist and a label it will only show one of them. (So far it's always the label)
Can't hurt I guess. |

Code and PR written by AI-tool
Problem
Fixes #795
On discography/band pages (e.g.
https://hibernate.bandcamp.com), the script looks up both artist and label relations for the page URL. The label lookup was using the bare URL as its cache key — the same key used by the artist lookup. When a label was found, its MBID was cached under the bare URL.On subsequent album page visits,
resolveMBID(root_url)(line 631) would find that cached label MBID under the bare URL and incorrectly assign it torelease.artist_credit[0].mbid, causing MusicBrainz to reject the import with:Evidence from localStorage cache (before fix)
{ "https://hibernate.bandcamp.com": { "urls": ["https://musicbrainz.org/label/ebd021f8-89b9-4363-8977-3751be350572"] } }A label MBID stored under the bare URL key — read by
resolveMBID()as if it were an artist.Fix
Add a
label:prefix to the cache key on line 781, matching the pattern already used on album pages (line 610):Cache after fix
{ "https://hibernate.bandcamp.com": { "urls": [] }, "label:https://hibernate.bandcamp.com": { "urls": ["https://musicbrainz.org/label/ebd021f8-89b9-4363-8977-3751be350572"] } }Label MBID is now namespaced.
resolveMBID(root_url)correctly finds nothing (empty artist result), so no bogus MBID is seeded into the artist credit.Testing
Tested on https://hibernate.bandcamp.com/album/the-state-of-shining (the example from #795). After clearing the localStorage cache and revisiting the page, the import button works correctly without the
Invalid artist_crediterror.