mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-25 23:45:52 +03:00
[GH-ISSUE #525] JSON parse error because Spotify returns wrong data #167
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#167
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 @davidemarcoli on GitHub (May 24, 2025).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/525
Describe the bug
A clear and concise description of what the bug is.
The spotify returns wrong data which isn't being handled and an exception is thrown.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
It can parse the response without exception
Log/Output data
If applicable, add log data or output data to help explain your problem.
data did not match any variant of untagged enum PlayableItem at line 1 column 86707Additional context
Add any other context about the problem here.
Playlist which it fails for: https://open.spotify.com/playlist/0hnM986qSkpI9YSFwpl96E/
Example of an item:
https://open.spotify.com/episode/60XIexbGJJYcc2R5idt8p4
The api returns track=true and episode=false, which obviously is not true
@ramsayleung commented on GitHub (May 26, 2025):
Which API you were trying to call to get the playlist?
@davidemarcoli commented on GitHub (May 26, 2025):
I used the
playlist_items_manualfunction.Meaning the following spotify endpoint:
https://api.spotify.com/v1/playlists/0hnM986qSkpI9YSFwpl96E/tracks@ramsayleung commented on GitHub (May 27, 2025):
This is my unit test, it's passed, I can't re-produce this problem:
Could you run this test, and post your output?
@DrunkenToast commented on GitHub (Jul 6, 2025):
Running into the same issue, although not with the playlist above, instead with this one:
4MAcblnU4nwtIZ267YI24aThe output of the request is this: out.txt
Seems to be on the video thumbnail? One of the tracks is a podcast episode. Not sure where the issue lies but hope it helps.
@ramsayleung commented on GitHub (Jul 7, 2025):
The root cause should be the
"type": "REALPODCASTNOTMUSIC123", Spotify rollouts a new type again.It's a recurring problem I encounter again and again, I couldn't count how many times Spotify rollout a new field or new variant without properly updating their CHANGELOG, and user will create an issue to report the JSON deserialization error.
I am proposing a more robust way to minimize the impact to this library.
@DrunkenToast commented on GitHub (Jul 7, 2025):
That seems like the most sensible solution. Thanks for the hard work. The Spotify API seems like quite a mess :)
@ramsayleung commented on GitHub (Jul 8, 2025):
I eventually figure out the root cause of this JSON error, I can reproduce the problem with this test:
The problem is that the
PlayableItemenum expects either aTrackorEpisode, but the JSON contains a hybrid object that has characteristics of both.But based on API doc of get playlist item:
It's pretty frustrating.
@ramsayleung commented on GitHub (Jul 8, 2025):
The patch has been merged into the main branch, currently you could consume the main branch to resolve the JSON error until I release a new version.
@DrunkenToast commented on GitHub (Jul 8, 2025):
Hahaha, hilarious! Beautiful API design and documentation.
Thank you again for resolving this so quickly! I was using reqwest manually as temporary solution but I am happy to switch back to this library. :)
@hrkfdn commented on GitHub (Aug 26, 2025):
Hey @ramsayleung, thanks a lot for fixing this. I'm also getting user reports that look like this. Any chance of a patch release soon? :)
@ramsayleung commented on GitHub (Aug 28, 2025):
Request received and processed, the new version of this patch is out :)
https://crates.io/crates/rspotify
@hrkfdn commented on GitHub (Aug 28, 2025):
Thanks so much! :)