phergie / phergie-irc-plugin-react-url

Phergie plugin for displaying information about URLs
MIT License
0 stars 4 forks source link

GuzzleHttp\Exception\RequestException in resolveCallback throwing fatal error #12

Closed svpernova09 closed 8 years ago

svpernova09 commented 8 years ago

From the PHP log:

PHP Catchable fatal error:  Argument 1 passed to Phergie\Irc\Plugin\React\Url\Plugin::Phergie\Irc\Plugin\React\Url\{closure}() must be an instance of GuzzleHttp\Message\Response, instance of GuzzleHttp\Exception\RequestException given, called in /home/phergie/phergie-freenode/vendor/phergie/phergie-irc-plugin-http/src/Request.php on line 98 and defined in /home/phergie/phergie-freenode/vendor/phergie/phergie-irc-plugin-react-url/src/Plugin.php on line 180

Current tagged version of both plugins (http and url) on version 2 of the bot.

Url that caused the issue: http://www.senzati.com/jet-sprinter/

elazar commented 8 years ago

Not sure if this is related or not, but the site appears to be sniffing user agents.

Compare:

$ curl -v http://www.senzati.com/jet-sprinter/
Trying 84.18.209.67...
* Connected to www.senzati.com (84.18.209.67) port 80 (#0)
> GET /jet-sprinter/ HTTP/1.1
> Host: www.senzati.com
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 406 Not Acceptable
<snip>

To:

$ curl -v -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' http://www.senzati.com/jet-sprinter/
Trying 84.18.209.67...
* Connected to www.senzati.com (84.18.209.67) port 80 (#0)
> GET /jet-sprinter/ HTTP/1.1
> Host: www.senzati.com
> Accept: */*
> User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36
>
< HTTP/1.1 200 OK
<snip>

406 response to using curl versus 200 response "using" Chrome.

svpernova09 commented 8 years ago

Should we check response codes before passing it back to the callback then? Seems like that may be a way to catch it before it passes the ResponseException into the callback.

elazar commented 8 years ago

The problem may be that we need to turn http_errors off in the HTTP plugin; I'm not sure its existing mechanisms to allow for error handling will work otherwise. @WyriHaximus could probably speak better to whether that's the right approach, though.

WyriHaximus commented 8 years ago

That isn't correct, should be passed in from the reject callback :/

elazar commented 8 years ago

@WyriHaximus Should the call be callReject() rather than callResolve() here and here, then? It seems like the issue is that the HTTP plugin is neither turning http_errors off nor handling ResponseException if it occurs.

WyriHaximus commented 8 years ago

@elazar correct, on all 4 accounts. Shitty bug to sneak in let me fix it

svpernova09 commented 8 years ago

Fixed in phergie/phergie-irc-plugin-http (4.0.1)