[GH-ISSUE #33] Error running overnight #21

Closed
opened 2026-02-27 20:07:43 +03:00 by kerem · 1 comment
Owner

Originally created by @tomballgithub on GitHub (Feb 1, 2026).
Original GitHub issue: https://github.com/misiektoja/spotify_profile_monitor/issues/33

Overnight I saw this with the latest dev build:

Traceback (most recent call last):
  File "C:\spotify_profile_monitor\spotify_profile_monitor.py", line 6668, in <module>
    main()
    ~~~~^^
  File "C:\spotify_profile_monitor\spotify_profile_monitor.py", line 6661, in main
    spotify_profile_monitor_uri(args.user_id, CSV_FILE, playlists_to_skip)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\spotify_profile_monitor\spotify_profile_monitor.py", line 5686, in spotify_profile_monitor_uri
    stable_uris = set(playlists_old or [])
TypeError: cannot use 'dict' as a set element (unhashable type: 'dict')

from this code:

            user_playlists_key = f"user:{user_uri_id}"
            stable_entry = PLAYLISTS_BASELINE_CACHE.get(user_playlists_key)
            if stable_entry is None:
                # Initialize baseline from previously persisted playlist snapshot (if available)
                stable_uris = set(playlists_old or [])
                stable_count = playlists_old_count
                PLAYLISTS_BASELINE_CACHE[user_playlists_key] = {"uris": stable_uris, "count": stable_count}
                stable_entry = PLAYLISTS_BASELINE_CACHE[user_playlists_key]

Just for fun, I pasted everything above exactly as-is into Claude and got:

The issue is that playlists_old contains dictionaries (playlist objects), but you're trying to create a set from them. Dictionaries are unhashable and can't be added to sets. Looking at your code, you likely want to extract just the URIs from the playlist objects. Here's the fix:

user_playlists_key = f"user:{user_uri_id}"
stable_entry = PLAYLISTS_BASELINE_CACHE.get(user_playlists_key)
if stable_entry is None:
    # Initialize baseline from previously persisted playlist snapshot (if available)
    if playlists_old:
        # Extract URIs from playlist dictionaries
        stable_uris = {p['uri'] for p in playlists_old}
    else:
        stable_uris = set()
    stable_count = playlists_old_count
    PLAYLISTS_BASELINE_CACHE[user_playlists_key] = {"uris": stable_uris, "count": stable_count}
    stable_entry = PLAYLISTS_BASELINE_CACHE[user_playlists_key]

This assumes each playlist object has a 'uri' key. If the key is different (like 'id' or 'playlist_uri'), adjust accordingly.

Originally created by @tomballgithub on GitHub (Feb 1, 2026). Original GitHub issue: https://github.com/misiektoja/spotify_profile_monitor/issues/33 Overnight I saw this with the latest dev build: ``` Traceback (most recent call last): File "C:\spotify_profile_monitor\spotify_profile_monitor.py", line 6668, in <module> main() ~~~~^^ File "C:\spotify_profile_monitor\spotify_profile_monitor.py", line 6661, in main spotify_profile_monitor_uri(args.user_id, CSV_FILE, playlists_to_skip) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\spotify_profile_monitor\spotify_profile_monitor.py", line 5686, in spotify_profile_monitor_uri stable_uris = set(playlists_old or []) TypeError: cannot use 'dict' as a set element (unhashable type: 'dict') ``` from this code: ``` user_playlists_key = f"user:{user_uri_id}" stable_entry = PLAYLISTS_BASELINE_CACHE.get(user_playlists_key) if stable_entry is None: # Initialize baseline from previously persisted playlist snapshot (if available) stable_uris = set(playlists_old or []) stable_count = playlists_old_count PLAYLISTS_BASELINE_CACHE[user_playlists_key] = {"uris": stable_uris, "count": stable_count} stable_entry = PLAYLISTS_BASELINE_CACHE[user_playlists_key] ``` Just for fun, I pasted everything above exactly as-is into Claude and got: The issue is that playlists_old contains dictionaries (playlist objects), but you're trying to create a set from them. Dictionaries are unhashable and can't be added to sets. Looking at your code, you likely want to extract just the URIs from the playlist objects. Here's the fix: ``` user_playlists_key = f"user:{user_uri_id}" stable_entry = PLAYLISTS_BASELINE_CACHE.get(user_playlists_key) if stable_entry is None: # Initialize baseline from previously persisted playlist snapshot (if available) if playlists_old: # Extract URIs from playlist dictionaries stable_uris = {p['uri'] for p in playlists_old} else: stable_uris = set() stable_count = playlists_old_count PLAYLISTS_BASELINE_CACHE[user_playlists_key] = {"uris": stable_uris, "count": stable_count} stable_entry = PLAYLISTS_BASELINE_CACHE[user_playlists_key] ``` This assumes each playlist object has a 'uri' key. If the key is different (like 'id' or 'playlist_uri'), adjust accordingly.
kerem closed this issue 2026-02-27 20:07:43 +03:00
Author
Owner

@misiektoja commented on GitHub (Feb 1, 2026):

Ugh ... and this kids why you do not code after a heavy party and then immediately push without testing like nothing could possibly go wrong ;-) Sorry, should be fixed now in 0d7753efef.

<!-- gh-comment-id:3832044592 --> @misiektoja commented on GitHub (Feb 1, 2026): Ugh ... and this kids why you do not code after a heavy party and then immediately push without testing like nothing could possibly go wrong ;-) Sorry, should be fixed now in 0d7753efef.
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/spotify_profile_monitor#21
No description provided.