[GH-ISSUE #947] Question about Regex check for URI/URL #568

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

Originally created by @Musikfreitag on GitHub (Mar 8, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/947

I'm using URIs of playlists to retrieve song ids from a set of playlists.
Example: spotify:user:ultramusicofficial:playlist:1uQ4QCJhdIZodiLvE6dXKN

There was a change to include a regex check on these URIs: github.com/spotipy-dev/spotipy@b1db0b63d9 (comments)

After this change, my script was no longer working and returned the following error:

\spotipy\client.py", line 1988, in _get_id raise SpotifyException(400, -1, "Unsupported URL / URI.") spotipy.exceptions.SpotifyException: http status: 400, code:-1 - Unsupported URL / URI., reason: None
Why does this happen? Is this error really expected?
The URI seems valid to me and worked in the version before this change was introduced.

Originally created by @Musikfreitag on GitHub (Mar 8, 2023). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/947 I'm using URIs of playlists to retrieve song ids from a set of playlists. Example: spotify:user:ultramusicofficial:playlist:1uQ4QCJhdIZodiLvE6dXKN There was a change to include a regex check on these URIs: https://github.com/spotipy-dev/spotipy/commit/b1db0b63d90eae40af32d7ee4c760c2fd581a1b4#comments After this change, my script was no longer working and returned the following error: `\spotipy\client.py", line 1988, in _get_id raise SpotifyException(400, -1, "Unsupported URL / URI.") spotipy.exceptions.SpotifyException: http status: 400, code:-1 - Unsupported URL / URI., reason: None ` Why does this happen? Is this error really expected? The URI seems valid to me and worked in the version before this change was introduced.
kerem 2026-02-27 23:23:24 +03:00
Author
Owner

@stephanebruckert commented on GitHub (Mar 11, 2023):

Didn't know spotify:user:ultramusicofficial:playlist:1uQ4QCJhdIZodiLvE6dXKN was a valid URI. Indeed it needs to be fixed.

<!-- gh-comment-id:1464901621 --> @stephanebruckert commented on GitHub (Mar 11, 2023): Didn't know `spotify:user:ultramusicofficial:playlist:1uQ4QCJhdIZodiLvE6dXKN` was a valid URI. Indeed it needs to be fixed.
Author
Owner

@HighnessAtharva commented on GitHub (Apr 8, 2023):

Please close this issue. PR is already merged.

<!-- gh-comment-id:1500872222 --> @HighnessAtharva commented on GitHub (Apr 8, 2023): Please close this issue. PR is already merged.
Author
Owner

@deadlocker8 commented on GitHub (Oct 3, 2023):

I still encounter this problem even with the latest version 2.23.

The file read_a_playlist.py from the examples folder can be used to reproduce the error: https://github.com/spotipy-dev/spotipy/blob/master/examples/read_a_playlist.py

The fix introduced by https://github.com/spotipy-dev/spotipy/pull/949 actually causes the _regex_spotify_uri regex to result in a match, but the result then seems to be discarded in the next if-clause, since there is not match for the regex-group type.

In addition, my Spotify username contains a hyphen (-). At the moment the regex does not allow this.
I did not found any official documentation to check if other characters are allowed besides A-Z, a-z and 0-9. I can only tell for the hyphen in my username.

<!-- gh-comment-id:1745387296 --> @deadlocker8 commented on GitHub (Oct 3, 2023): I still encounter this problem even with the latest version 2.23. The file `read_a_playlist.py` from the examples folder can be used to reproduce the error: https://github.com/spotipy-dev/spotipy/blob/master/examples/read_a_playlist.py The fix introduced by https://github.com/spotipy-dev/spotipy/pull/949 actually causes the `_regex_spotify_uri` regex to result in a match, but the result then seems to be discarded in the next if-clause, since there is not match for the regex-group `type`. In addition, my Spotify username contains a hyphen (`-`). At the moment the regex does not allow this. I did not found any official documentation to check if other characters are allowed besides A-Z, a-z and 0-9. I can only tell for the hyphen in my username.
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/spotipy#568
No description provided.