Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError from intercom/request (again) #467

Closed
sidonath opened this issue Apr 3, 2019 · 9 comments
Closed

NoMethodError from intercom/request (again) #467

sidonath opened this issue Apr 3, 2019 · 9 comments

Comments

@sidonath
Copy link
Contributor

sidonath commented Apr 3, 2019

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.

@theandrewykim
Copy link
Contributor

@sidonath Hey there! Is there a specific request that you made that returned this error? That'd be really helpful in getting to the bottom of which response we're not accounting for here. Thanks!

@sidonath
Copy link
Contributor Author

Hi @theandrewykim! Doesn't seem like there's something very specific, here's the breakdown:

  • events.create - 1 occurrence
  • users.find - 7 occurrences
  • users.save - 2 occurrences

@theandrewykim
Copy link
Contributor

@sidonath Thanks! Do you mind sharing your app_id with me? Maybe there is a specific error code being thrown that we're not accounting for shared between these three endpoints.

@sidonath
Copy link
Contributor Author

sidonath commented Apr 11, 2019

@theandrewykim Sure, our ID is f6jrsmcb.

In case it helps, here are the timestamps of occurrences (EST):

2019-03-29 05:35 pm	
2019-03-30 06:42 am	
2019-03-30 06:42 am	
2019-03-30 06:42 am	
2019-03-30 06:42 am	
2019-03-30 06:43 am	
2019-03-30 06:43 am	
2019-03-30 06:43 am
2019-03-30 06:43 am	
2019-04-02 07:22 pm	

The large cluster on Mar 30th at 6:42/6:43 is interesting.

@theandrewykim
Copy link
Contributor

@sidonath Sorry for leaving this one hanging! I thought I had gotten back to this. We didn't have access to the logs for the time frame you had written in about. Are you still running into issues with this?

@sidonath
Copy link
Contributor Author

@theandrewykim Hi! We didn't get any new occurrences of this error for 3 months now.

Do you think it would still make sense to change raise_errors_on_failure to provide more details as originally suggested?

@sidonath
Copy link
Contributor Author

sidonath commented Jul 2, 2019

@theandrewykim Hi there! We had the same exception again at 2019-07-01 08:54 pm EDT.

@kmossco
Copy link

kmossco commented Jul 6, 2019

We are currently having the same problem.

Ruby 2.3.8
Intercom client 3.7.5

Intercom::UnexpectedError: The error of type '' is not recognized. It occurred with the message: Server Error and http_code: '500'. Please contact Intercom with these details.

This happens on the following line in my code: intercom.companies.save(ic_company). It seems to happen when your API is down, and as @sidonath mentioned this happens when the HTTP code fails to be recognised.

Reached out to support to understand if they could help, they mentioned the developers were informed, a few weeks have passed so just in case adding it here too. Let me know if there's anything I can help with. I don't like the idea of ignoring this error as it can then cause me to miss out on other errors that need my attention.

@sidonath
Copy link
Contributor Author

sidonath commented Nov 5, 2019

Should be resolved with #492.

@sidonath sidonath closed this as completed Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants