-
-
Notifications
You must be signed in to change notification settings - Fork 11
Fix issue TypeError: Cannot read properties of undefined (reading 'runs') at Module.get_playlist #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ns') at Module.get_playlist
vixalien
left a comment
There was a problem hiding this 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>
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>
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>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this 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_playlistto safely accessstraplineTextOne.runs - Enhanced
parse_song_artists_runswith 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 |
|
Hello, please don't mind copilot everytime (fix the last change and you'd be ready to go) |
|
Now it should be good, sorry @vixalien for the continuos copilot commit that make me had done changes and then revert them, damn AI |
vixalien
left a comment
There was a problem hiding this 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
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_runsfunction.Error Handling Improvements:
src/mixins/playlist.ts: Updated theauthorsproperty in theget_playlistfunction to use optional chaining (?.) when accessingrunsto prevent potential runtime errors ifstraplineTextOneis undefined.src/parsers/songs.ts: Added a null check at the beginning of theparse_song_artists_runsfunction to return an empty array ifrunsis falsy, ensuring the function handles invalid input gracefully.Code Readability Enhancements:
src/parsers/songs.ts: Removed unnecessary whitespace and simplified the loop structure in theparse_song_artists_runsfunction for better readability.