ramsayleung / rspotify

Spotify Web API SDK implemented on Rust
MIT License
639 stars 123 forks source link

`TrackLink::id` can be `null` #486

Closed aome510 closed 1 month ago

aome510 commented 2 months ago

id field in TrackLink can be null.

To reproduce, call

curl --request GET \
      --url "https://api.spotify.com/v1/albums/5dIJ97uGTWrNmw6QRwMnRo" \
      --header 'Authorization: Bearer $TOKEN'

Expected response:

{"album_type":"single","total_tracks":1,"available_markets":["JP"],"external_urls":{"spotify":"https://open.spotify.com/album/5dIJ97uGTWrNmw6QRwMnRo"},"href":"https://api.spotify.com/v1/albums/5dIJ97uGTWrNmw6QRwMnRo","id":"5dIJ97uGTWrNmw6QRwMnRo","images":[{"url":"https://i.scdn.co/image/ab67616d0000b273cbd185b2883c3e898afe3d48","height":640,"width":640},{"url":"https://i.scdn.co/image/ab67616d00001e02cbd185b2883c3e898afe3d48","height":300,"width":300},{"url":"https://i.scdn.co/image/ab67616d00004851cbd185b2883c3e898afe3d48","height":64,"width":64}],"name":"Off The Record","release_date":"2023-10-06","release_date_precision":"day","type":"album","uri":"spotify:album:5dIJ97uGTWrNmw6QRwMnRo","artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/6RHTUrRF63xao58xh9FXYJ"},"href":"https://api.spotify.com/v1/artists/6RHTUrRF63xao58xh9FXYJ","id":"6RHTUrRF63xao58xh9FXYJ","name":"IVE","type":"artist","uri":"spotify:artist:6RHTUrRF63xao58xh9FXYJ"}],"tracks":{"href":"https://api.spotify.com/v1/albums/5dIJ97uGTWrNmw6QRwMnRo/tracks?offset=0&limit=50","limit":50,"next":null,"offset":0,"previous":null,"total":1,"items":[{"artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/6RHTUrRF63xao58xh9FXYJ"},"href":"https://api.spotify.com/v1/artists/6RHTUrRF63xao58xh9FXYJ","id":"6RHTUrRF63xao58xh9FXYJ","name":"IVE","type":"artist","uri":"spotify:artist:6RHTUrRF63xao58xh9FXYJ"}],"available_markets":["JP"],"disc_number":1,"duration_ms":188733,"explicit":false,"external_urls":{"spotify":"https://open.spotify.com/track/0tSkMuKKrLXEfxc58cEhFX"},"href":"https://api.spotify.com/v1/tracks/3G7MgLuWLzUJQflWOCDZit","id":"3G7MgLuWLzUJQflWOCDZit","linked_from":{"external_urls":{"spotify":"https://open.spotify.com/track/0tSkMuKKrLXEfxc58cEhFX"},"href":"https://api.spotify.com/v1/tracks/0tSkMuKKrLXEfxc58cEhFX","id":null,"type":"track","uri":"spotify:track:0tSkMuKKrLXEfxc58cEhFX"},"name":"Off The Record","preview_url":"https://p.scdn.co/mp3-preview/3346ec86648d6aebb9cd5fc4693c3e534719d12a?cid=b28a574d8ad44fc7b5a89994431a8f88","track_number":1,"type":"track","uri":"spotify:track:3G7MgLuWLzUJQflWOCDZit","is_local":false}]},"copyrights":[{"text":"(P) 2023 STARSHIP ENTERTAINMENT","type":"P"}],"external_ids":{"upc":"4547366649536"},"genres":[],"label":"Sony Music Labels Inc.","popularity":45}

Observe that "id":null in the linked_from payload.

Context: I found out this issue when debugging https://github.com/aome510/spotify-player/issues/519

ramsayleung commented 2 months ago

I can reproduce this problem with the album id provided above, I've created a PR to fix this issue.

aome510 commented 1 month ago

Thanks @ramsayleung!