[GH-ISSUE #28] Spotify change? Substring "correlationId":" not found in JSON string #16

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

Originally created by @shillshocked on GitHub (Mar 29, 2025).
Original GitHub issue: https://github.com/Aran404/SpotAPI/issues/28

I've been getting errors with script functions that have worked for a long while. Got some insight on that from an AI:

I examined the source code in
GITHUB.COM
. In the get_session method, after fetching the Spotify homepage (https://open.spotify.com/), the code calls:

self.device_id = parse_json_string(resp.response, "correlationId")
This function (located in spotapi/utils/strings.py) searches for the substring "correlationId": in the response and raises a ValueError if it isn’t found. It appears that Spotify has likely changed its page structure so that this substring is no longer present in the response. That is why your script is failing with the error:

Substring "correlationId":" not found in JSON string

To resolve the issue, you can try one or more of the following approaches:

Patch the Parsing Logic:
Modify the parse_json_string() or adjust get_session in spotapi/client.py so it correctly extracts the needed device identifier from the current page response. For example, you might change the regex or add a fallback to handle the new structure.

Patch Example:
In spotapi/utils/strings.py, you might change:

raise ValueError(f'Substring "{s}":" not found in JSON string')
to something like:

if f'"{s}":' not in json_string:
print(f'Warning: "{s}" not found in JSON. Proceeding without it.')
return None # or some default value
Note that this is a temporary fix; a proper solution may require updating the library to align with Spotify’s current API.

Alternative Authentication Flow:
If the device ID isn’t strictly necessary for your use case, you might bypass that check or supply a default value.

Originally created by @shillshocked on GitHub (Mar 29, 2025). Original GitHub issue: https://github.com/Aran404/SpotAPI/issues/28 I've been getting errors with script functions that have worked for a long while. Got some insight on that from an AI: I examined the source code in [​](https://github.com/Aran404/SpotAPI/blob/main/spotapi/client.py) GITHUB.COM . In the get_session method, after fetching the Spotify homepage (https://open.spotify.com/), the code calls: self.device_id = parse_json_string(resp.response, "correlationId") This function (located in spotapi/utils/strings.py) searches for the substring "correlationId": in the response and raises a ValueError if it isn’t found. It appears that Spotify has likely changed its page structure so that this substring is no longer present in the response. That is why your script is failing with the error: Substring "correlationId":" not found in JSON string To resolve the issue, you can try one or more of the following approaches: Patch the Parsing Logic: Modify the parse_json_string() or adjust get_session in spotapi/client.py so it correctly extracts the needed device identifier from the current page response. For example, you might change the regex or add a fallback to handle the new structure. Patch Example: In spotapi/utils/strings.py, you might change: raise ValueError(f'Substring "{s}":" not found in JSON string') to something like: if f'"{s}":' not in json_string: print(f'Warning: "{s}" not found in JSON. Proceeding without it.') return None # or some default value Note that this is a temporary fix; a proper solution may require updating the library to align with Spotify’s current API. Alternative Authentication Flow: If the device ID isn’t strictly necessary for your use case, you might bypass that check or supply a default value.
kerem closed this issue 2026-02-27 19:06:27 +03:00
Author
Owner

@shillshocked commented on GitHub (Mar 29, 2025):

I was able to get it to continue to work (with warnings) using this updated code in strings.py:

def parse_json_string(b: str, s: str) -> str:
    start_index = b.find(f'{s}":"')
    if start_index == -1:
        """raise ValueError(f'Substring "{s}":" not found in JSON string')"""
        if f'"{s}":' not in b:
            print(f'Warning: "{s}" not found in JSON. Proceeding without it.')
            return None  # or some default value
<!-- gh-comment-id:2763302655 --> @shillshocked commented on GitHub (Mar 29, 2025): I was able to get it to continue to work (with warnings) using this updated code in strings.py: ``` def parse_json_string(b: str, s: str) -> str: start_index = b.find(f'{s}":"') if start_index == -1: """raise ValueError(f'Substring "{s}":" not found in JSON string')""" if f'"{s}":' not in b: print(f'Warning: "{s}" not found in JSON. Proceeding without it.') return None # or some default value ```
Author
Owner

@Leogendra commented on GitHub (Mar 31, 2025):

I'm providing a code example that reproduces the error:

from spotapi import PublicPlaylist

playlist = PublicPlaylist("6zCID88oNjNv9zx6puDHKj")
playlist_info = playlist.get_playlist_info()

Which gives the following error:

  File "/spotapi/utils/strings.py", line 44, in parse_json_string
    raise ValueError(f'Substring "{s}":" not found in JSON string')
ValueError: Substring "correlationId":" not found in JSON string
<!-- gh-comment-id:2766191780 --> @Leogendra commented on GitHub (Mar 31, 2025): I'm providing a code example that reproduces the error: ```python from spotapi import PublicPlaylist playlist = PublicPlaylist("6zCID88oNjNv9zx6puDHKj") playlist_info = playlist.get_playlist_info() ``` Which gives the following error: ```bash File "/spotapi/utils/strings.py", line 44, in parse_json_string raise ValueError(f'Substring "{s}":" not found in JSON string') ValueError: Substring "correlationId":" not found in JSON string ```
Author
Owner

@Aran404 commented on GitHub (Apr 14, 2025):

Sorry, is this issue still relevant?

<!-- gh-comment-id:2802923100 --> @Aran404 commented on GitHub (Apr 14, 2025): Sorry, is this issue still relevant?
Sign in to join this conversation.
No labels
pull-request
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/SpotAPI#16
No description provided.