Repository navigation
fix(applemusic): handle tracks without albumName - #833
Merged
Merged
Conversation
The recently-played history can return a track with no albumName, and formatPlayObj called .replace() on it when album normalization was enabled (the default). The TypeError failed the whole poll until the source stopped polling. Only normalize the album name when it is present. A track without one now results in a play with no album. Fixes FoxxMD#825 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
👷 Deploy request for multi-scrobbler pending review.Visit the deploys page to approve it
|
Owner
Could be worth doing a patch update to correct this typing! |
Contributor
Probably should but I still want to get the song or track that was responsible for that beforehand... My best guess is it is a library song, which (if I understand correctly) can be a locally imported song without any kind of metadata. Everything in the Apple Music catalogue should have an album name. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
Type of change
Describe your changes
AppleMusicSource.formatPlayObjcalled.replace()ontrack.albumNamewithout checking that it exists. One recently-played track with no album failed the whole poll, and after the maximum number of retries the source stopped polling.The replace now uses optional chaining, so such a track produces a play with
data.albumundefined. Albums that are present are normalized as before.node-musickit-apitypesalbumNameas a requiredstring, so the compiler does not flag this. The other track fields read informatPlayObj(artistName,name,isrc,durationInMillis,url) are not dereferenced there, so they did not need a change.Testing, on Node 24:
albumName, withnormalizeAlbumboth on and off. Without the fix it fails withTypeError: Cannot read properties of undefined (reading 'replace').tsc -p src/backend --noEmitpasses.oxlinton the two changed files reports warnings only. The new test usesas anylike the existing mock tracks in that file.This was not tested against the live Apple Music API.
Issue number and link, if applicable
Fixes #825
This PR was prepared with AI assistance (Claude) and reviewed before submission.
🤖 Generated with Claude Code