I’m a little confused with how the API accepts ports. If I iterate through my current firewalls’ inbound rules, I can see this:

[29] pry(#<DigitalOceanAPI>)> @firewalls["PivotSSH"].inbound_rules
=> [<DropletKit::FirewallInboundRule {:@protocol=>"tcp", :@ports=>"8443", :@sources=>{"addresses"=>["redcacted"], "droplet_ids"=>[redacted]}}>,
 <DropletKit::FirewallInboundRule {:@protocol=>"tcp", :@ports=>"31000-32000", :@sources=>{"addresses"=>["redacted"], "droplet_ids"=>[redacted]}}>]

As you can see above, it looks like the ports is set to “31000-32000” which just looks like a string. However, if I take an existing firewall object and modify its ports to the same thing, the API doesn’t like it when calling the .update function:

[30] pry(#<DigitalOceanAPI>)> firewall
=> <DropletKit::Firewall {:@id=>"redacted, :@name=>"vPenTestAgents", :@status=>"succeeded", :@created_at=>"2020-06-22T03:24:05Z", :@inbound_rules=><DropletKit::FirewallInboundRule {:@protocol=>"tcp", :@ports=>[31000, 32000], :@sources=>{:addresses=>[""]}}>, :@outbound_rules=>[<DropletKit::FirewallOutboundRule {:@protocol=>"icmp", :@ports=>"0", :@destinations=>{"addresses"=>["", "::/0"]}}>, <DropletKit::FirewallOutboundRule {:@protocol=>"tcp", :@ports=>"0", :@destinations=>{"addresses"=>["", "::/0"]}}>, <DropletKit::FirewallOutboundRule {:@protocol=>"udp", :@ports=>"0", :@destinations=>{"addresses"=>["", "::/0"]}}>], :@droplet_ids=>[redacted], :@tags=>[], :@pending_changes=>[]}>
[32] pry(#<DigitalOceanAPI>)> @client.firewalls.update(firewall)
DropletKit::FailedUpdate: You must specify a positive value for ports.
from /usr/local/rvm/gems/ruby-2.5.8/gems/droplet_kit-3.8.0/lib/droplet_kit/mappings/error_mapping.rb:16:in `fail_with'
[33] pry(#<DigitalOceanAPI>)>

Any idea what could be going on here? It’s weird that I just can’t update the value from what it is currently to the same object type (string) and have it work.

I can’t even take an unmodified firewall and update itself without getting an error about the ports. I can’t understand why this would happen.

If I do something like firewall = client.firewalls.find(id: "xyz"); client.firewalls.update(firewall) then it gives me the same error about the ports. Makes no sense.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

Still having this exact same issue. No updates??

Submit an Answer