vrt-ruby icon indicating copy to clipboard operation
vrt-ruby copied to clipboard

VRT::Map#find_node hits uninformative error when passed bad input

Open adamrdavid opened this issue 7 years ago • 0 comments
trafficstars

This error is thrown at: https://github.com/bugcrowd/vrt-ruby/blob/master/lib/vrt/map.rb#L21:

def find_node(string, max_depth: 'variant')
  # return nil unless valid_identifier?(string)
  @_found_nodes[string + max_depth] ||= walk_node_tree(string, max_depth: max_depth)
end

when param: string == nil

     NoMethodError:
       undefined method `+' for nil:NilClass
     # ./lib/vrt/map.rb:22:in `find_node'

when param: !string.is_a? String

     TypeError:
       String can't be coerced into Fixnum
     # ./lib/vrt/map.rb:22:in `+'
     # ./lib/vrt/map.rb:22:in `find_node'

Should be fine to just return nil in these cases since that is what we do when no node can be found.

adamrdavid avatar May 30 '18 23:05 adamrdavid