digitalocean / digitalocean/droplet_kit

paginated_resource raises error with no api key set

Open
#59 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
521
Forks
151
PR merge metrics
No merged PRs in 30d

Description

```
client = DropletKit::Client.new(access_token: nil)
client.droplets.all.each do |droplet|
puts droplet.name
end
=> TypeError: no implicit conversion of String into Array
from /Users/jadems/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/droplet_kit-1.2.3/lib/droplet_kit/paginated_resource.rb:68:in `retrieve'
from /Users/jadems/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/droplet_kit-1.2.3/lib/droplet_kit/paginated_resource.rb:60:in `fetch_next_page'
from /Users/jadems/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/droplet_kit-1.2.3/lib/droplet_kit/paginated_resource.rb:26:in `each'
```

I had a misconfigured environment and spent a few minutes trying to figure out why I was getting this. It might be helpful to handle authentication errors more gracefully.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with lib/droplet_kit/paginated_resource.rb, especially retrieve around line 68 and fetch_next_page around line 60, then reproduce the issue using a client with a nil access token and droplets.all. Trace how the authentication failure becomes a TypeError; done means the misconfigured client reports an understandable authentication error instead.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.