[GH-ISSUE #587] KeyError: "Unable to find 'menu' using path #407

Closed
opened 2026-02-27 23:00:38 +03:00 by kerem · 3 comments
Owner

Originally created by @ClintGreen5150 on GitHub (May 23, 2024).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/587

I am very new to this so I apologize if I'm doing this wrong...

I'm trying to create playlists of a few thousand tracks but I keep hitting this keyerror. It's completely intermittent, occurs on a different track each time. I am using the search function to find an album, grabbing the albumID and using that to browse to the album, then selecting a random track and using its ID to add it to the playlist. This seems to happen around the 200 track mark but it has also happened after adding about 80 tracks in this manner.

I've tried batching the artist/album data to chunks of 100 but the issue persists.

To Reproduce
Steps to reproduce the behavior:
I really am not sure unfortunately, it is intermittent, it just happens on a random track when trying to add to a playlist.

Additional context
Using the latest version, 1.7.2

Originally created by @ClintGreen5150 on GitHub (May 23, 2024). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/587 I am very new to this so I apologize if I'm doing this wrong... I'm trying to create playlists of a few thousand tracks but I keep hitting this keyerror. It's completely intermittent, occurs on a different track each time. I am using the search function to find an album, grabbing the albumID and using that to browse to the album, then selecting a random track and using its ID to add it to the playlist. This seems to happen around the 200 track mark but it has also happened after adding about 80 tracks in this manner. I've tried batching the artist/album data to chunks of 100 but the issue persists. **To Reproduce** Steps to reproduce the behavior: I really am not sure unfortunately, it is intermittent, it just happens on a random track when trying to add to a playlist. **Additional context** Using the latest version, 1.7.2
kerem 2026-02-27 23:00:38 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sigma67 commented on GitHub (May 23, 2024):

Hi, thanks for the report.

Please provide the full stack trace and error message, including the search term you used.

<!-- gh-comment-id:2127770484 --> @sigma67 commented on GitHub (May 23, 2024): Hi, thanks for the report. Please provide the full stack trace and error message, including the search term you used.
Author
Owner

@ClintGreen5150 commented on GitHub (May 23, 2024):

I hope this is correct and what you are looking for - I am still learning code, 2 months in :)

Search results for blackened entrails - manifesto sepulcral:
[{'title': 'manifesto sepulcral', 'artist': 'blackened entrails', 'browseId': 'MPREb_RME6sh1SHeK', 'resultType': 'album'}]
Traceback (most recent call last):
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\navigation.py", line 106, in nav
root = root[k]
~~~~^^^
KeyError: 'menu'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator\YT_playlist_gen.py", line 127, in
search_results = yt.search(search_query)
^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\mixins\search.py", line 236, in search
parse_search_results(shelf_contents, search_result_types, result_type, category)
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\parsers\search.py", line 178, in parse_search_results
parse_search_result(result[MRLIR], search_result_types, resultType, category) for result in results
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\parsers\search.py", line 91, in parse_search_result
parse_menu_playlists(data, search_result)
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\parsers_utils.py", line 7, in parse_menu_playlists
watch_menu = find_objects_by_key(nav(data, MENU_ITEMS), MNIR)
^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\navigation.py", line 110, in nav
raise type(e)(f"Unable to find '{k}' using path {items!r} on {root!r}, exception: {e}")
KeyError: "Unable to find 'menu' using path ['menu', 'menuRenderer', 'items'] on {'trackingParams': 'CBAQyfQCGAAiEwi9rbHTwqSGAxWJyEkHHdMEDDM=', 'thumbnail': {'musicThumbnailRenderer': {'thumbnail':
{}, 'thumbnailCrop': 'MUSIC_THUMBNAIL_CROP_CIRCLE', 'thumbnailScale': 'MUSIC_THUMBNAIL_SCALE_ASPECT_FILL', 'trackingParams': 'CBEQhL8CIhMIva2x08KkhgMVichJBx3TBAwz'}}, 'flexColumns': [{'musicResponsiveListItemFlexColumnRenderer': {'text': {'runs': [{'text': 'Jianxin Li'}]}, 'displayPriority': 'MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH'}}, {'musicResponsiveListItemFlexColumnRenderer': {'text': {'runs': [{'text': 'Profile'}]}, 'displayPriority': 'MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH'}}], 'flexColumnDisplayStyle': 'MUSIC_RESPONSIVE_LIST_ITEM_FLEX_COLUMN_DISPLAY_STYLE_TWO_LINE_STACK', 'navigationEndpoint': {'clickTrackingParams': 'CBAQyfQCGAAiEwi9rbHTwqSGAxWJyEkHHdMEDDM=', 'browseEndpoint': {'browseId': 'UC_usPjyxDU93yOVnY32_b_Q', 'browseEndpointContextSupportedConfigs': {'browseEndpointContextMusicConfig': {'pageType': 'MUSIC_PAGE_TYPE_UNKNOWN'}}}}, 'itemHeight': 'MUSIC_RESPONSIVE_LIST_ITEM_HEIGHT_TALL'}, exception: 'menu'"

<!-- gh-comment-id:2127897633 --> @ClintGreen5150 commented on GitHub (May 23, 2024): I hope this is correct and what you are looking for - I am still learning code, 2 months in :) Search results for blackened entrails - manifesto sepulcral: [{'title': 'manifesto sepulcral', 'artist': 'blackened entrails', 'browseId': 'MPREb_RME6sh1SHeK', 'resultType': 'album'}] Traceback (most recent call last): File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator\.conda\Lib\site-packages\ytmusicapi\navigation.py", line 106, in nav root = root[k] ~~~~^^^ KeyError: 'menu' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator\YT_playlist_gen.py", line 127, in <module> search_results = yt.search(search_query) ^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator\.conda\Lib\site-packages\ytmusicapi\mixins\search.py", line 236, in search parse_search_results(shelf_contents, search_result_types, result_type, category) File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator\.conda\Lib\site-packages\ytmusicapi\parsers\search.py", line 178, in parse_search_results parse_search_result(result[MRLIR], search_result_types, resultType, category) for result in results ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator\.conda\Lib\site-packages\ytmusicapi\parsers\search.py", line 91, in parse_search_result parse_menu_playlists(data, search_result) File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator\.conda\Lib\site-packages\ytmusicapi\parsers\_utils.py", line 7, in parse_menu_playlists watch_menu = find_objects_by_key(nav(data, MENU_ITEMS), MNIR) ^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator\.conda\Lib\site-packages\ytmusicapi\navigation.py", line 110, in nav raise type(e)(f"Unable to find '{k}' using path {items!r} on {root!r}, exception: {e}") KeyError: "Unable to find 'menu' using path ['menu', 'menuRenderer', 'items'] on {'trackingParams': 'CBAQyfQCGAAiEwi9rbHTwqSGAxWJyEkHHdMEDDM=', 'thumbnail': {'musicThumbnailRenderer': {'thumbnail': {}, 'thumbnailCrop': 'MUSIC_THUMBNAIL_CROP_CIRCLE', 'thumbnailScale': 'MUSIC_THUMBNAIL_SCALE_ASPECT_FILL', 'trackingParams': 'CBEQhL8CIhMIva2x08KkhgMVichJBx3TBAwz'}}, 'flexColumns': [{'musicResponsiveListItemFlexColumnRenderer': {'text': {'runs': [{'text': 'Jianxin Li'}]}, 'displayPriority': 'MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH'}}, {'musicResponsiveListItemFlexColumnRenderer': {'text': {'runs': [{'text': 'Profile'}]}, 'displayPriority': 'MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH'}}], 'flexColumnDisplayStyle': 'MUSIC_RESPONSIVE_LIST_ITEM_FLEX_COLUMN_DISPLAY_STYLE_TWO_LINE_STACK', 'navigationEndpoint': {'clickTrackingParams': 'CBAQyfQCGAAiEwi9rbHTwqSGAxWJyEkHHdMEDDM=', 'browseEndpoint': {'browseId': 'UC_usPjyxDU93yOVnY32_b_Q', 'browseEndpointContextSupportedConfigs': {'browseEndpointContextMusicConfig': {'pageType': 'MUSIC_PAGE_TYPE_UNKNOWN'}}}}, 'itemHeight': 'MUSIC_RESPONSIVE_LIST_ITEM_HEIGHT_TALL'}, exception: 'menu'"
Author
Owner

@sigma67 commented on GitHub (May 25, 2024):

@ClintGreen5150 please check if the linked PR fixes it

<!-- gh-comment-id:2131108341 --> @sigma67 commented on GitHub (May 25, 2024): @ClintGreen5150 please check if the linked PR fixes it
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#407
No description provided.