rocket-chat
rocket-chat copied to clipboard
401 responses not correctly error-handled
When the Rocket.Chat REST API responds with 401 due to invalid authentication, the response looks like this (prettified):
{
"status": "error",
"message": "You must be logged in to do this."
}
However, the error handling in the Request::send
method is a mere success handler (literally, by checking if the JSON response has a success
property with a falsy value):
https://github.com/alekseykuleshov/rocket-chat/blob/66895dce433035efb2d1a17541de492a5170489b/src/Common/Request.php#L125-L139
The final bool
return value of the method, (static::$responseCode >= 200) && (static::$responseCode < 300)
, could handle this case but Request::send
s return value appears to be unused elsewhere in the package.