mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #845] Search query longer than 100 characters returns an error #522
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#522
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @duracell013 on GitHub (Aug 11, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/845
Describe the bug
The search method returns an error when the query string is longer than 100 characters. Is this a limitation of the Spotify web API?
Your code
Expected behavior
The search method should be able to handle queries of more than 100 characters
Output for the first search with 100-character string [OK]
Output for the second search with 101-character string [NOT OK]
Environment:
@stephanebruckert commented on GitHub (Aug 22, 2022):
I can confirm I'm seeing 404s for searches with queries longer than 100 characters since end of April 2022. It doesn't make any sense because many tracks+artist that long. It's also not documented in the doc.
Please upvote https://community.spotify.com/t5/Spotify-for-Developers/V1-API-Search-q-query-parameter-appears-to-have-a-limit-of-100/td-p/5398898
In spotipy I wonder how this should be handled, because 404 Not Found is wrong, it should be a 400 Bad Request. When
len(query) > 100, should we:search()@duracell013 commented on GitHub (Aug 22, 2022):
@stephanebruckert thanks for confirming the issue. I've upvoted the post on the Spotify API website.
@Razlif commented on GitHub (Oct 13, 2022):
looks like spotify fixed the return code issue, they now return 400.
sent a query longer than 100 chars and got the following:
@stephanebruckert commented on GitHub (Oct 29, 2022):
This is good but yeah, the problem is still there.
Personally I'm ignoring queries that are > 100 but that's because my use case allows it. Trimming the query would be not only difficult but also opinionated, because all queries are personalised. In the case of a complex query, what to trim? a 50-char long artist, or a 80-char long track?
What we could do at first is display a warning when we get a 400 and the query is > 100. This way if one day the API changes the limit from 100 to another number, spotipy won't be preventing the request.
In the future we might want to create a util to cleanse queries. The idea to remove brackets https://github.com/rootshellz/Beatporter/issues/15#issuecomment-1241714508 is quite good.