[GH-ISSUE #805] get_library_playlists results in a KeyError #504

Closed
opened 2026-02-27 23:01:09 +03:00 by kerem · 6 comments
Owner

Originally created by @apastel on GitHub (Aug 22, 2025).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/805

  • [ X] I confirm that I have read the FAQ

Describe the bug

A user of my application that uses ytmusicapi is experiencing a KeyError when the app calls get_library_playlists(limit=1).

Traceback (most recent call last):
  File "ytmusicapi\navigation.py", line 122, in nav
KeyError: 'runs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 590, in <module>
  File "main.py", line 566, in run
  File "main.py", line 540, in window
  File "main.py", line 150, in init
  File "main.py", line 262, in update_buttons
  File "main.py", line 196, in is_signed_in
  File "ytmusicapi\mixins\library.py", line 44, in get_library_playlists
  File "ytmusicapi\parsers\browsing.py", line 57, in parse_content_list
  File "ytmusicapi\parsers\browsing.py", line 141, in parse_playlist
  File "ytmusicapi\navigation.py", line 126, in nav
KeyError: "Unable to find 'runs' using path ['title', 'runs', 0, 'text'] on {}, exception: 'runs'"

ytmusicapi version

1.10.3

To Reproduce

Steps to reproduce the behavior:

  1. Be this particular user.
  2. Attempt to execute yt.get_library_playlists(limit=1) (although I imagine the limit is irrelevant here).

Additional context

If this is an A/B testing issue, I know the best way to solve this is usually to get a copy of the user's JSON response from the browser's dev tools, but I'm not sure which request it is that we want to look at. Is it browse?

Originally created by @apastel on GitHub (Aug 22, 2025). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/805 - [ X] I confirm that I have read the [FAQ](https://ytmusicapi.readthedocs.io/en/stable/faq.html#why-is-ytmusicapi-returning-more-results-than-requested-with-the-limit-parameter) **Describe the bug** A user of my application that uses ytmusicapi is experiencing a `KeyError` when the app calls `get_library_playlists(limit=1)`. ``` Traceback (most recent call last): File "ytmusicapi\navigation.py", line 122, in nav KeyError: 'runs' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "main.py", line 590, in <module> File "main.py", line 566, in run File "main.py", line 540, in window File "main.py", line 150, in init File "main.py", line 262, in update_buttons File "main.py", line 196, in is_signed_in File "ytmusicapi\mixins\library.py", line 44, in get_library_playlists File "ytmusicapi\parsers\browsing.py", line 57, in parse_content_list File "ytmusicapi\parsers\browsing.py", line 141, in parse_playlist File "ytmusicapi\navigation.py", line 126, in nav KeyError: "Unable to find 'runs' using path ['title', 'runs', 0, 'text'] on {}, exception: 'runs'" ``` **ytmusicapi version** 1.10.3 **To Reproduce** Steps to reproduce the behavior: 1. Be this particular user. 2. Attempt to execute `yt.get_library_playlists(limit=1)` (although I imagine the `limit` is irrelevant here). **Additional context** If this is an A/B testing issue, I know the best way to solve this is usually to get a copy of the user's JSON response from the browser's dev tools, but I'm not sure which request it is that we want to look at. Is it `browse`?
kerem 2026-02-27 23:01:09 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sigma67 commented on GitHub (Aug 22, 2025):

Have you tried 1.11.0?

At least in our tests we aren't having this problem, so it could also be specific to your library or account as you suggested.

<!-- gh-comment-id:3214933601 --> @sigma67 commented on GitHub (Aug 22, 2025): Have you tried 1.11.0? At least in our tests we aren't having this problem, so it could also be specific to your library or account as you suggested.
Author
Owner

@apastel commented on GitHub (Aug 22, 2025):

I misrepresented which ytmusicapi version they are using. 1.10.3 was cached on my system but I got the output of their system:

ytmusicapi version: 1.11.0

Yes since this hasn't happened with other users of my app I believe it's probably specific to their account and not a bug with the API but maybe an A/B test. I just wasn't sure how else to report it (maybe in Discussions?)

Is there a particular JSON response that I should ask them for that we can look at to confirm?

<!-- gh-comment-id:3215018077 --> @apastel commented on GitHub (Aug 22, 2025): I misrepresented which ytmusicapi version they are using. 1.10.3 was cached on my system but I got the output of their system: ``` ytmusicapi version: 1.11.0 ``` Yes since this hasn't happened with other users of my app I believe it's probably specific to their account and not a bug with the API but maybe an A/B test. I just wasn't sure how else to report it (maybe in Discussions?) Is there a particular JSON response that I should ask them for that we can look at to confirm?
Author
Owner

@sigma67 commented on GitHub (Aug 23, 2025):

Yeah that would be helpful. Just the JSON response when going to the Library Playlists page. Maybe also a screenshot of the layout of the page, in case something is changing there

<!-- gh-comment-id:3216677811 --> @sigma67 commented on GitHub (Aug 23, 2025): Yeah that would be helpful. Just the JSON response when going to the Library Playlists page. Maybe also a screenshot of the layout of the page, in case something is changing there
Author
Owner

@apastel commented on GitHub (Aug 24, 2025):

Well after looking at a screenshot of their playlists, I'm pretty sure I know what the problem is.

Image

He's got this playlist at the beginning with no name and no tracks. It's a total zombie, he can't do anything to get rid of it, it seems. There's a "Remove playlist from library" context menu option, but the playlist just comes back when refreshing. Same on mobile. So it seems like it's permanently stuck there. Based on the stack trace, it seems like it's choking on "title" which makes sense because there isn't one.

Here is the response JSON for the library playlists page, but I didn't find anything unusual about the format or anything, which is again why I think it's an issue with this one broken playlist: playlists.json

So since this broken playlist seems to be permanently stuck, and since I've never encountered this before, in the meantime I may just monkeypatch the parse_playlist function in my application to use none_if_absent for "title". But if you wanted to make that a change in ytmusicapi itself, that's up to you. I could understand not wanting to make that change for this rare occurence, but I guess it could happen to other users too.

<!-- gh-comment-id:3217498151 --> @apastel commented on GitHub (Aug 24, 2025): Well after looking at a screenshot of their playlists, I'm pretty sure I know what the problem is. <img width="1563" height="1277" alt="Image" src="https://github.com/user-attachments/assets/c5cc2b23-b0ba-42af-9dfe-fb93d5843cbc" /> He's got this playlist at the beginning with no name and no tracks. It's a total zombie, he can't do anything to get rid of it, it seems. There's a "Remove playlist from library" context menu option, but the playlist just comes back when refreshing. Same on mobile. So it seems like it's permanently stuck there. Based on the stack trace, it seems like it's choking on "title" which makes sense because there isn't one. Here is the response JSON for the library playlists page, but I didn't find anything unusual about the format or anything, which is again why I think it's an issue with this one broken playlist: [playlists.json](https://github.com/user-attachments/files/21952662/playlists.json) So since this broken playlist seems to be permanently stuck, and since I've never encountered this before, in the meantime I may just monkeypatch the `parse_playlist` function in my application to use `none_if_absent` for "title". But if you wanted to make that a change in ytmusicapi itself, that's up to you. I could understand not wanting to make that change for this rare occurence, but I guess it could happen to other users too.
Author
Owner

@apastel commented on GitHub (Aug 24, 2025):

The user downloaded my app with the monkeypatched parser and it worked for them.

My patch added this to the beginning of parse_playlist

if not nav(data, TITLE_TEXT, none_if_absent=True):
        logging.debug(f"Encountered playlist without a title: \n{data}")
        return {"title": "<broken playlist>", "playlistId": "Unknown ID"}
<!-- gh-comment-id:3218283262 --> @apastel commented on GitHub (Aug 24, 2025): The user downloaded my app with the monkeypatched parser and it worked for them. My patch added this to the beginning of `parse_playlist` ``` if not nav(data, TITLE_TEXT, none_if_absent=True): logging.debug(f"Encountered playlist without a title: \n{data}") return {"title": "<broken playlist>", "playlistId": "Unknown ID"} ```
Author
Owner

@sigma67 commented on GitHub (Aug 24, 2025):

PR welcome

<!-- gh-comment-id:3218384546 --> @sigma67 commented on GitHub (Aug 24, 2025): PR welcome
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#504
No description provided.