Skip to content

fix(bandcamp_importer): namespace label cache key on discography pages#930

Open
chaban-mb wants to merge 1 commit into
murdos:masterfrom
chaban-mb:bandcamp-importer/fix/label-mbid-cache-collision
Open

fix(bandcamp_importer): namespace label cache key on discography pages#930
chaban-mb wants to merge 1 commit into
murdos:masterfrom
chaban-mb:bandcamp-importer/fix/label-mbid-cache-collision

Conversation

@chaban-mb

@chaban-mb chaban-mb commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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 to release.artist_credit[0].mbid, causing MusicBrainz to reject the import with:

Invalid artist_credit.names.0.mbid

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):

-mblinks.searchAndDisplayMbLink(cleanURL, 'label', insertLinkCb, undefined, onSearchComplete);
+mblinks.searchAndDisplayMbLink(cleanURL, 'label', insertLinkCb, `label:${cleanURL}`, onSearchComplete);

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_credit error.

… 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
@arsinclair

Copy link
Copy Markdown
Collaborator

I suspect that it is the same problem that leads to #797. Could you verify that this fix also resolves that problem?
Example release: https://dronarivm.bandcamp.com/album/air-signs

image

Also, do you think it makes sense to prefix artist lookups as well, so there's never an ambiguity?

@chaban-mb

chaban-mb commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Example release: https://dronarivm.bandcamp.com/album/air-signs

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)
E.g. https://altersynth.bandcamp.com/

Also, do you think it makes sense to prefix artist lookups as well, so there's never an ambiguity?

Can't hurt I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bandcamp Importer causes Invalid artist_credit MB error when importing certain releases

2 participants