-
Notifications
You must be signed in to change notification settings - Fork 137
Description
Version info
- intercom-ruby version: 3.7.6
- Ruby version: 2.5.3
Expected behavior
intercom-ruby does not raise NoMethodError.
Actual behavior
Same issue as in #339 that's still not fixed properly.
We started getting undefined method '[]' for nil:NilClass at lib/intercom/request.rb:114 after upgrading from 3.5.25 to 3.7.5 and then to 3.7.6. But the problem is older than 3.5.25, so that's probably unrelated.
This exception was first fixed in #353, and then reverted/fixed in #359, by adding a handler for nil:
raise_errors_on_failure(response) if parsed_body.nil?
raise_application_errors_on_failure(parsed_body, response.code.to_i) if parsed_body['type'] == 'error.list'The problem, however, is that, contrary to the name, raise_errors_on_failure doesn't always raise: if it doesn't recognize the HTTP status code it doesn't do anything, so nil propagates to the next line.
Maybe raise_errors_on_failure should raise for every response with code >= 400 or at least log the error somehow?
Steps to reproduce
I'm not sure how to reproduce it. I don't know which response from Intercom triggers this exception, but the server responding with any unhandled status code without body would trigger the exception.