mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 07:55:55 +03:00
[GH-ISSUE #141] Percent sign in search query leads to a 400 #49
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#49
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 @Utagai on GitHub (Oct 19, 2020).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/141
I found this while using
spotify-tui. After some digging, it seems like the issue is coming fromrspotify.Using a
%symbol in your query string when calling thesearchfunction leads to a 400. Here's a quick and tiny snippet fromspotify-tui:If
&search_termabove were to be, e.g.,99% invisible, we get a HTTP 400.However, if we escape it as
99%25 invisible, the query goes through as expected.It is unclear to me why we don't see other issues, like, why space
' 'is not necessary to explicitly escape as'%20'. I'm new to rust but I imagine that perhaps space is handled already somehow/somewhere in the stack when we use theRequestBuilder.@marioortizmanero commented on GitHub (Oct 19, 2020):
I can reproduce your issue. Here's a minimal working example I wrote with 0.10.0:
I tried to reproduce after the rewrite in the master branch, using ureq as the client, expecting it to be fixed:
But it seems to be an issue still... Interestingly, this is what happens with reqwest:
It seems to be related to
SearchType::Show, since withSearchType::Artistit does work.@Utagai commented on GitHub (Oct 19, 2020):
Interesting! I did not realize this was a show-specific bug. Thanks for looking into that.
It seems like you're already taking a look at this, but let me know if you need anything else.
This isn't a major issue with
spotify-tui, especially since we can cheekily search "99%25 invisible" and have it still work 😉.@kstep commented on GitHub (Mar 9, 2021):
I tried to reproduce the bug. With
SearchType::Artistit returns an empty result (items: []), so I guess that's why it "works ok".For
SearchType::Showit returns an array of nulls (items: [null, null, null, ...]), hence theinvalid type: null, expected struct SimplifiedShowerror.@kstep commented on GitHub (Mar 9, 2021):
It seems the problem is in the invalid auth token.
I tried to reproduce the bug in the developer console (https://developer.spotify.com/console/), and it works just OK, no problems!
Then I tried to make the query in my terminal with curl with an auth token from the developer console, and it worked OK as well.
But then I tried to do it with an auth token I got from the code above (from this issue), and the bug was reproduced (I got
items: [null, ...]in response)!@kstep commented on GitHub (Mar 10, 2021):
If the bug is related to the authentication process, is it possible it will be fixed (or otherwise affected) by #173 ?
@marioortizmanero commented on GitHub (Mar 10, 2021):
I mean #173 is meant to be a rewrite, but the functionality will be the same. The plan is to copy most of the codebase, only restructuring and tidying it up a bit.
But hey who knows maybe after that it'll magically work :P
I'm waiting to see if #191 can be sorted out beforehand, as two PRs restructuring the project at the same time doesn't sound like a good idea.
@marioortizmanero commented on GitHub (Sep 25, 2021):
Apparently this has been fixed in
master. I've added a test in #259.