Skip to content
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

Options are nil when fetching playlists #270

Open
fwcd opened this issue Nov 29, 2024 · 1 comment
Open

Options are nil when fetching playlists #270

fwcd opened this issue Nov 29, 2024 · 1 comment

Comments

@fwcd
Copy link

fwcd commented Nov 29, 2024

A tool I built using this library has begun crashing for me two days ago:

/opt/hostedtoolcache/Ruby/3.3.0/x64/lib/ruby/gems/3.3.0/gems/rspotify-2.12.4/lib/rspotify/playlist.rb:97:in `initialize': undefined method `[]' for nil (NoMethodError)

      @collaborative = options['collaborative']
                              ^^^^^^^^^^^^^^^^^
	from /opt/hostedtoolcache/Ruby/3.3.0/x64/lib/ruby/gems/3.3.0/gems/rspotify-2.12.4/lib/rspotify/user.rb:285:in `new'
	from /opt/hostedtoolcache/Ruby/3.3.0/x64/lib/ruby/gems/3.3.0/gems/rspotify-2.12.4/lib/rspotify/user.rb:285:in `block in playlists'
	from /opt/hostedtoolcache/Ruby/3.3.0/x64/lib/ruby/gems/3.3.0/gems/rspotify-2.12.4/lib/rspotify/user.rb:285:in `map'
	from /opt/hostedtoolcache/Ruby/3.3.0/x64/lib/ruby/gems/3.3.0/gems/rspotify-2.12.4/lib/rspotify/user.rb:285:in `playlists'
        from /opt/hostedtoolcache/Ruby/3.3.0/x64/lib/ruby/gems/3.3.0/gems/drum-0.2.3/lib/drum/service/spotify.rb:247:in `all_sp_library_playlists'

Here is the relevant library call.

@thepavangollapalli
Copy link

thepavangollapalli commented Dec 1, 2024

This seems to be because Spotify started returning nil as part of the list of playlists returned by the get user playlists endpoint.

 "items"=>[nil, {valid playlist object}, {valid playlist object}, ...]

The library expects response['items'] to only contain valid playlist objects and passes them directly to Playlist.new to initialize. I was able to fix this locally by dropping nil values:

response['items'].compact.map { |i| Playlist.new i }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants