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

rate_limit_details open interface could be nil, when it should not be. X-RateLimit-Reset needs a guard if its not returned from server

Open Goran1708 opened this issue 3 years ago • 0 comments

Version info

  • intercom-ruby version: 4.1.2
  • Ruby version: 2.7.1

Expected behavior

  1. Should not throw error if server does not return x rate limit reset at date
  2. rate_limit_details should not be set to nil if the http client throws an error

This is the PR solution https://github.com/intercom/intercom-ruby/pull/578

Actual behavior

  1. If intercom server returns X-RateLimit-Reset as nil it would crash the app
  2. rate_limit_details becomes nil instead of empty hash if the http client throws an error, while the public interface of the rate_limit_details should always be either empty hash or hash with some data.

Steps to reproduce

  1. X-RateLimit-Reset should not be returned from the server, while handle_rate_limit should be enabled.
  2. This is hard to reproduce because http client initial request on line 61 in class Request "response = http.request(net_http_method)" needs to throw an error, which would set rate_limit_details to nil in the Client class.

Logs

Bug regarding rate_limit_details happened to us because we tried to use rate_limit_details for some custom solution's and at one point it became nil which crash our process.

Goran1708 avatar Dec 17 '21 09:12 Goran1708