digitalocean / digitalocean/droplet_kit

Action 'delete' is already defined on `DropletKit::CDNResource`

Open
#305 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

Hi! Any call to droplet_kit api gives me this error:
```
ArgumentError: Action 'delete' is already defined on `DropletKit::CDNResource`
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/resource_kit-0.1.8/lib/resource_kit/method_factory.rb:6:in `block in construct'
C:/Ruby31-x64/lib/ruby/3.1.0/forwardable.rb:238:in `each'
C:/Ruby31-x64/lib/ruby/3.1.0/forwardable.rb:238:in `each'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/resource_kit-0.1.8/lib/resource_kit/method_factory.rb:4:in `construct'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/resource_kit-0.1.8/lib/resource_kit/resource.rb:20:in `resources'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/resources/cdn_resource.rb:7:in `'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/resources/cdn_resource.rb:4:in `'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/resources/cdn_resource.rb:3:in `'
:96:in `require'
:96:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/client.rb:34:in `resources'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/client.rb:69:in `method_missing'
```

I've commented out this exception in resource_kit/method_factory.rb like this:
```ruby
module ResourceKit
class MethodFactory
def self.construct(object, resource_collection, invoker = ActionInvoker)
resource_collection.each do |action|
if object.method_defined?(action.name)
# raise ArgumentError, "Action '#{action.name}' is already defined on `#{object}`"
next
end
```

And it works fine. Exception raised for delete action for each resource.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at resource_kit/method_factory.rb and the CDNResource definition in droplet_kit/resources/cdn_resource.rb, then trace loading through droplet_kit/client.rb. Reproduce the resource-loading failure and compare it with the reported workaround. Done means DropletKit resources load and API calls no longer raise the duplicate delete-action error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.