yandex-cleanweb icon indicating copy to clipboard operation
yandex-cleanweb copied to clipboard

Yandex-cleanweb fails to handle invalid response from Yandex.Cleanweb the service

Open natikgadzhi opened this issue 13 years ago • 5 comments

When the response comes in invalid, yandex-cleanweb fails with the following:

NoMethodError: undefined method `content' for nil:NilClass
File "/home/amplifr/amplifr/shared/bundle/ruby/2.0.0/bundler/gems/yandex-cleanweb-f244a29261a2/lib/yandex_cleanweb.rb" line 22 in spam?

So my guess is that api_check_spam should check if the response is 200, and if it's not, an exception should be thrown. spam? should handle the exception and have an optional parameter of the default policy whether it should consider messages that failed to be tested as spam or not. If no such parameter is provided, spam? should consider these messages as valid, non-spam messages.

natikgadzhi avatar Jul 19 '13 21:07 natikgadzhi

Do you have an example of invalid query?

kirs avatar Jul 20 '13 09:07 kirs

ping @xnutsive

kirs avatar Jul 24 '13 23:07 kirs

Nope, no examples.

We send params[something] to spam?, so there might be some junk, however I don't think the reason of the failure is in example — it might be network issues or whatever else.

Do you think it's a good idea to handle those exceptions inside spam?? We can actually rescue those in our code and it'd still work ok for us.

natikgadzhi avatar Jul 25 '13 11:07 natikgadzhi

You're right, I need to add custom exception that will be raised in case if non-200 response code.

kirs avatar Jul 25 '13 12:07 kirs

@xnutsive done. I've released 0.0.6 which raises YandexCleanweb::BadResponseException in case of empty response.

kirs avatar Jul 26 '13 08:07 kirs