Giter Club home page Giter Club logo

Comments (11)

alaz avatar alaz commented on July 21, 2024 1

Ah, you are saying this issue is a duplicate of #112 . Then it should be closed, because they are fixed via #113 and can not be reproduced in 1.9.4. Thank you for the information.

I am happy to discuss improvements to the code in a PR if you are willing to contribute. Thank you.

from legitbot.

FunkyloverOne avatar FunkyloverOne commented on July 21, 2024

Hey @alaz, why not use dig here?

results[AS][family][AS]

That NoMethodError is not the best way to raise an exception here, I think. 😅

from legitbot.

alaz avatar alaz commented on July 21, 2024

@Hanaffi , it seems to be something with your network. Try debugging with whois. You can use the command from the page on Facebook Crawler as a starting point.

from legitbot.

alaz avatar alaz commented on July 21, 2024

@FunkyloverOne , do you mean dig as an executable? The first of all, it may not be present in the system. The second, it would be worse security-wise.

from legitbot.

FunkyloverOne avatar FunkyloverOne commented on July 21, 2024

@alaz , no, I mean a method, here: https://ruby-doc.org/3.2.0/Hash.html#method-i-dig
So the code would look like this:

results.dig(AS,family, AS)

Even if there is some network issue, if some error must be raised here - it better not be NoMethodError, but rather something meaningful, WDYT?

from legitbot.

alaz avatar alaz commented on July 21, 2024

@FunkyloverOne thanks for clarifying. Feel free to put up a PR. Please do remember that the minimal supported Ruby version is 2.7 at the moment:

ruby: [ jruby, 2.7, 3.0, 3.1, 3.2 ]

from legitbot.

FunkyloverOne avatar FunkyloverOne commented on July 21, 2024

@alaz no problem at all, here it is in 2.7.0: https://ruby-doc.org/core-2.7.0/Hash.html#method-i-dig

from legitbot.

joancodes avatar joancodes commented on July 21, 2024

@alaz Was a PR created for this?

from legitbot.

FunkyloverOne avatar FunkyloverOne commented on July 21, 2024

I was thinking about how to best approach this situation, I think that we would want to introduce a custom error, something like Legitbot::IPRangeNotFoundError, inherited from Legitbot::Error < StandardError, so that for consumers it would be possible to rescue from those errors and react to them how they see fit.

But also, when do we want to raise it?
Like this?

%i[ipv4 ipv6].map do |family|
  results.dig(AS, family, AS) || raise Legitbot::IPRangeNotFoundError
end.flatten

Or like this:

ranges = %i[ipv4 ipv6].map do |family|
  results.dig(AS, family, AS) || raise Legitbot::IPRangeNotFoundError
end.flatten.compact
raise Legitbot::IPRangeNotFoundError if ranges.empty?

ranges

from legitbot.

alaz avatar alaz commented on July 21, 2024

@FunkyloverOne what situation? No one has helped debug this problem further

If networks with malfunctioning whois are the issue here, I suggest thinking backwards from the client code point of view. They need to know that the initialisation phase has failed and be told why.

from legitbot.

FunkyloverOne avatar FunkyloverOne commented on July 21, 2024

The situation is the following - if for whatever reason (network issue or Facebook changing something on their side) the results hash does not have the required keys - this code fails with NoMethodError. What's here to debug?
I propose to raise the appropriate error instead of NoMethodError, so that it can be rescued and handled accordingly.

As far as I'm aware - you can reproduce this error by simply using this gem version prior to 1.9.4.
This error was kind of fixed here: #113
But, that PR fixes configuration for Facebook, but does not address the NoMethodError which would be cumbersome to rescue if any kind of similar hiccup happens again.

from legitbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.