Skip to content

Conversation

@nico-iaco
Copy link
Contributor

I was having an issue with the get_playlist method of this library, after getting some playlist from the get_home method when I was trying to get the details of the playlist it gave me this error: TypeError: Cannot read properties of undefined (reading 'runs') at Module.get_playlist (file:///Users/myUser/myProject/node_modules/libmuse/esm/src/mixins/playlist.js:57:66).
This pull request makes improvements to error handling and code readability in the playlist and song parsing functionality. The most notable changes include adding safety checks to prevent runtime errors and simplifying the parse_song_artists_runs function.

Error Handling Improvements:

  • src/mixins/playlist.ts: Updated the authors property in the get_playlist function to use optional chaining (?.) when accessing runs to prevent potential runtime errors if straplineTextOne is undefined.
  • src/parsers/songs.ts: Added a null check at the beginning of the parse_song_artists_runs function to return an empty array if runs is falsy, ensuring the function handles invalid input gracefully.

Code Readability Enhancements:

  • src/parsers/songs.ts: Removed unnecessary whitespace and simplified the loop structure in the parse_song_artists_runs function for better readability.

Copilot AI review requested due to automatic review settings July 4, 2025 14:37

This comment was marked as outdated.

Copy link
Owner

@vixalien vixalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few changes needed

Co-authored-by: Angelo Verlain Shema <37999241+vixalien@users.noreply.github.com>
@nico-iaco nico-iaco requested a review from Copilot July 7, 2025 12:16

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nico-iaco nico-iaco requested a review from Copilot July 7, 2025 12:19

This comment was marked as outdated.

nico-iaco and others added 2 commits July 7, 2025 18:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nico-iaco nico-iaco requested a review from Copilot July 7, 2025 16:15

This comment was marked as outdated.

@nico-iaco nico-iaco requested a review from vixalien July 7, 2025 16:18
nico-iaco and others added 3 commits July 18, 2025 11:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nico-iaco nico-iaco requested a review from Copilot July 18, 2025 09:46

This comment was marked as outdated.

nico-iaco and others added 2 commits July 18, 2025 11:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nico-iaco nico-iaco requested a review from Copilot July 18, 2025 09:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a runtime TypeError in the playlist functionality by adding defensive programming practices to handle undefined/null values. The changes primarily focus on preventing crashes when accessing properties of potentially undefined objects.

  • Added optional chaining in get_playlist to safely access straplineTextOne.runs
  • Enhanced parse_song_artists_runs with input validation and null checks
  • Simplified the parsing logic and improved code readability with better loop structure

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/mixins/playlist.ts Added optional chaining to prevent TypeError when accessing straplineTextOne.runs
src/parsers/songs.ts Added input validation, new Run interface, and simplified parsing logic with better error handling

@vixalien
Copy link
Owner

Hello, please don't mind copilot everytime (fix the last change and you'd be ready to go)

@nico-iaco
Copy link
Contributor Author

Now it should be good, sorry @vixalien for the continuos copilot commit that make me had done changes and then revert them, damn AI

Copy link
Owner

@vixalien vixalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Thanks for tolerating the Copilot bs

@vixalien vixalien merged commit afe0ec8 into vixalien:main Jul 18, 2025
1 check passed
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.

3 participants