ramsayleung / rspotify

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

`cursors` in `rspotify_model::page::CursorBasedPage` can be `None` #301

Closed aome510 closed 1 year ago

aome510 commented 2 years ago

Describe the bug The cursors field in the cursor-based page object can be null if the page returned by the request is empty. Assuming it is non-nullable makes deserializing the response object panic.

To Reproduce Steps to reproduce the behavior:

  1. Make a get-recently-played request
    curl --request GET \
     --url 'https://api.spotify.com/v1/me/player/recently-played?before=<random number, e.g 100>' \
     --header 'Authorization: Bearer <TOKEN> \
     --header 'Content-Type: application/json'

Expected behavior Found the cursors field in the response to be null.

marioortizmanero commented 2 years ago

Can confirm that I can reproduce this:

 curl --request GET \
     --url 'https://api.spotify.com/v1/me/player/recently-played?before=100' \
     --header "Authorization: Bearer $ACCESS_TOKEN" \
     --header 'Content-Type: application/json'
{
  "items" : [ ],
  "next" : null,
  "cursors" : null,
  "limit" : 20,
  "href" : "https://api.spotify.com/v1/me/player/recently-played?before=100"
}