-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json parse error when calling artist
method
#452
Comments
It's weird that the total and popularity are marked as integer in their official document, but actually return float data. I tried to reproduce this bug by following your instruction in the document console, but the response is different from yours. curl --request GET \
--url https://api.spotify.com/v1/artists/1dfeR4HaWDbWqFHLkxsg1d \
--header 'Authorization: Bearer $TOKEN' {
"external_urls": {
"spotify": "https://open.spotify.com/artist/1dfeR4HaWDbWqFHLkxsg1d"
},
"followers": {
"href": null,
"total": 49022656
},
"genres": ["classic rock", "glam rock", "rock"],
"href": "https://api.spotify.com/v1/artists/1dfeR4HaWDbWqFHLkxsg1d?locale=en-US%2Cen%3Bq%3D0.9%2Czh-CN%3Bq%3D0.8%2Czh%3Bq%3D0.7",
"id": "1dfeR4HaWDbWqFHLkxsg1d",
"images": [
{
"url": "https://i.scdn.co/image/b040846ceba13c3e9c125d68389491094e7f2982",
"height": 806,
"width": 999
},
{
"url": "https://i.scdn.co/image/af2b8e57f6d7b5d43a616bd1e27ba552cd8bfd42",
"height": 516,
"width": 640
},
{
"url": "https://i.scdn.co/image/c06971e9ff81696699b829484e3be165f4e64368",
"height": 161,
"width": 200
},
{
"url": "https://i.scdn.co/image/6dd0ffd270903d1884edf9058c49f58b03db893d",
"height": 52,
"width": 64
}
],
"name": "Queen",
"popularity": 84,
"type": "artist",
"uri": "spotify:artist:1dfeR4HaWDbWqFHLkxsg1d"
}
|
im getting this same error too, think spotify may have changed something because this was all fine yesterday {
"external_urls": {
"spotify": "https://open.spotify.com/artist/4bwIf0yXJf0F9AmOl2J78M"
},
"followers": {
"href": null,
"total": 194172.0
},
"genres": [
"denpa-kei",
"rhythm game"
],
"href": "https://api.spotify.com/v1/artists/4bwIf0yXJf0F9AmOl2J78M",
"id": "4bwIf0yXJf0F9AmOl2J78M",
"images": [
{
"url": "https://i.scdn.co/image/ab6761610000e5ebc1f9dd30f82038e91e865d82",
"height": 640.0,
"width": 640.0
},
{
"url": "https://i.scdn.co/image/ab67616100005174c1f9dd30f82038e91e865d82",
"height": 320.0,
"width": 320.0
},
{
"url": "https://i.scdn.co/image/ab6761610000f178c1f9dd30f82038e91e865d82",
"height": 160.0,
"width": 160.0
}
],
"name": "Camellia",
"popularity": 51.0,
"type": "artist",
"uri": "spotify:artist:4bwIf0yXJf0F9AmOl2J78M"
}``` |
Yes, I can reproduce your problem now, I've submitted a ticket to Spotify to ask for clarity: https://community.spotify.com/t5/Spotify-for-Developers/The-response-type-of-artist-endpoint-is-marked-as-Integer-in/m-p/5800044 |
Hi @ramsayleung, just so you know there is an error in the issue link |
Thanks for your heads-up, I've revised the link to the correct one. But it's odd that a developer replied in the ticket saying what he got with Unfortunately, this ticket is marked as spam... I've submitted an abuse report. |
Hey here! Developing an app for android and i have the same problem with the GETARTISTS endpoint |
I don't think Spotify will give their response anytime soon. I wonder if we have any plans to mitigate this issue @ramsayleung ? |
One of the workarounds comes to my mind is converting the Integer type to float type to bypass the issue. But in my perspective, I don't think it's a great idea because
I personally prefer to keep escalating and making "noise" to the Spotify developers, the louder noise we could make, the higher probability the Spotify team could be aware of this problem and fix it. |
I've sent a message to escalate this issue to the Spotify team via this link: https://support.spotify.com/ca-en/contact-spotify-support/, here is the response from their associate:
|
Great! Thank you @ramsayleung |
This issue is also holding up the development of a project of mine. If it isn't fixed soon by the spotify developers would rspotify support deserializing all This solution wouldn't introduce breaking changes in the API as @ramsayleung pointed out, and the fix would continue to work if spotify does get around to fixing the issue. Plus, it would only have the overhead of converting any given |
One thing you could do as a temporary workaround is this match rspotify
.api_get(&format!("artists/{}", artist_id), &Query::new())
.await
{
Ok(artist) => {
// Manually parse the json for now
let artist_json: Result<Value, _> = serde_json::from_str(&artist);
match artist_json {
}
}
```
im not sure if its the bestt way but its what im using for now and it seems to work alright, still learning stuff lol
but it stopped me from needing to halt development on my stuff temporarily |
But this temporary workaround only for the you, the sole developer who decides to engage this approach. I would try to implement the |
Should I contribute the fix? I can do it in the next two days unless you'd like to implement it yourself. |
I could provide the code snippet for your reference, feel free to contribute and issue a PR :) pub mod data_type_patcher {
use serde::{Deserialize, Deserializer};
pub fn as_u32<'de, D>(deserializer: D) -> Result<u32, D::Error>
where
D: Deserializer<'de>,
{
let float_data: f64 = Deserialize::deserialize(deserializer)?;
let u32_data = float_data as u32;
Ok(u32_data)
}
} |
As I didn't see any PR related to this I let myself to implement it #457. I tested it with https://github.com/aome510/spotify-player and it worked well. |
Due to Spotify API returning floats instead of uints for some fields of the Artist it cannot be parsed. This commit adds deserializing float values into u32 as a workaround. Related issue: [issue](ramsayleung#452) Signed-off-by: Maciej Torhan <mtorhan@antmicro.com>
Due to Spotify API returning floats instead of uints for some fields of the Artist it cannot be parsed. This commit adds deserializing float values into u32 as a workaround. Related issue: [issue](ramsayleung#452) Signed-off-by: Maciej Torhan <mtorhan@antmicro.com>
Due to Spotify API returning floats instead of uints for some fields of the Artist it cannot be parsed. This commit adds deserializing float values into u32 as a workaround. Related issue: [issue](ramsayleung#452) Signed-off-by: Maciej Torhan <mtorhan@antmicro.com>
Look like a workaround patch landed to |
I am on vacation right now, I will release a new version when I am back :)
…On Sun, Feb 4, 2024 at 1:34 AM Thang Pham ***@***.***> wrote:
Look like a workaround patch landed to master. @ramsayleung
<https://github.com/ramsayleung> do you have any plans to release a new
version?
—
Reply to this email directly, view it on GitHub
<#452 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADMGCSMC32AKD5FDO26MFZ3YRZYLXAVCNFSM6AAAAABBPP63O2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVGQYDQMRVGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I'm now getting the same error but with
Observe that many fields expecting integer return float. The response that I got
Not sure if the above issue is only reproducible on my end because the same request on https://developer.spotify.com/documentation/web-api/reference/get-several-tracks still returns the correct type. Found this issue when trying to investigate aome510/spotify-player#383 |
I have to say, it's "scope creep" of Spotify's bug, other developers have reported the same observation in other endpoints, it becomes less possible to be patched and bypassed individually by the community-driven library, this problem has to be fixed by the Spotify itself. |
Yeah, I agree. At the same time, it's kinda frustrating to see that Spotify doesn't seem to take any actions. |
The new version of RSpotify would like to pend for a while for the response from Spotify, since it's meanless to release a new version while Spotify keeps breaking their endpoints, the community is unable to catch up to release new patch. |
Resolves #330 Resolves #383 Resolves #384 Related upstream issues: - ramsayleung/rspotify#452 - ramsayleung/rspotify#459 This PR implements patches for upstream Spotify API bugs by using `client::Client::internal_call` to get Spotify data instead of `rspotify` APIs. Using `internal_call` allows the app's client to avoid parsing errors when `rspotify` parses Spotify API responses and fixes - artist page not loading - recommendation/radio tracks page not loading - playlist page not loading for playlists with no image
@aome510 @ramsayleung As expected this is caused by some library that they are using. I am using |
Closing since this issue has been resolved by Spotify. |
Describe the bug
Client now returns
for every
artist
request. The reason seems to be because Spotify changes the type offollowers.total
and other fields to float.To Reproduce
Steps to reproduce the behavior:
curl --request GET \ --url https://api.spotify.com/v1/artists/1dfeR4HaWDbWqFHLkxsg1d \ --header 'Authorization: Bearer $TOKEN'
follower.total
is not an integer. Example result:followers.total
,popularity
The text was updated successfully, but these errors were encountered: