ninech / netbox-client-ruby

A ruby client library for Netbox v2.
MIT License
24 stars 21 forks source link

flatten throws an error #39

Closed TvL2386 closed 3 years ago

TvL2386 commented 3 years ago

I've worked around this issue by concatting arrays, however, I think it is a bug that the following code throws an error:

> [[NetboxClientRuby::DCIM::Interface.new(name: 'ge-0/0/0', device_id: 488)]].flatten
NetboxClientRuby::LocalError: Received 'nil' while replacing ':id' in 'dcim/interfaces/:id.json' with a value.
from /usr/local/bundle/gems/netbox-client-ruby-0.5.2/lib/netbox_client_ruby/entity.rb:310:in `block in replace_path_variables_in'

The problem is Interface responds to flatten and throws an error:

> NetboxClientRuby::DCIM::Interface.new(name: 'ge-0/0/0', device_id: 488).flatten
NetboxClientRuby::LocalError: Received 'nil' while replacing ':id' in 'dcim/interfaces/:id.json' with a value.
from /usr/local/bundle/gems/netbox-client-ruby-0.5.2/lib/netbox_client_ruby/entity.rb:310:in `block in replace_path_variables_in'
thde commented 3 years ago

Hey @TvL2386, thanks for the report! I'm happy to review and merge if you find time for a PR.

TvL2386 commented 3 years ago

Hi @thde, you're welcome. I've tried to fix it, PR incoming.

thde commented 3 years ago

Released: https://github.com/ninech/netbox-client-ruby/releases/tag/0.5.3