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 in replaced raise_error method for Faraday::Response::RaiseError #32

Closed
contentfree opened this issue Nov 23, 2015 · 11 comments
Labels

Comments

@contentfree
Copy link

Stacktrace:

/usr/local/rvm/gems/ruby-2.1.4/gems/slack-ruby-client-0.4.0/lib/slack/web/faraday/response/raise_error.rb:8:in `on_complete': undefined method `[]' for nil:NilClass (NoMethodError)
    from /usr/local/rvm/gems/ruby-2.1.4/gems/faraday-0.9.2/lib/faraday/response.rb:9:in `block in call'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/faraday-0.9.2/lib/faraday/response.rb:57:in `on_complete'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/faraday-0.9.2/lib/faraday/response.rb:8:in `call'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/faraday-0.9.2/lib/faraday/response.rb:8:in `call'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/faraday-0.9.2/lib/faraday/request/url_encoded.rb:15:in `call'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/faraday-0.9.2/lib/faraday/request/multipart.rb:14:in `call'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/faraday-0.9.2/lib/faraday/rack_builder.rb:139:in `build_response'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/faraday-0.9.2/lib/faraday/connection.rb:377:in `run_request'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/faraday-0.9.2/lib/faraday/connection.rb:177:in `post'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/slack-ruby-client-0.4.0/lib/slack/web/faraday/request.rb:25:in `request'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/slack-ruby-client-0.4.0/lib/slack/web/faraday/request.rb:10:in `post'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/slack-ruby-client-0.4.0/lib/slack/web/api/endpoints/channels.rb:131:in `channels_list'

A guard needs to be added to handle the case when body isn't present

contentfree added a commit to contentfree/slack-ruby-client that referenced this issue Nov 23, 2015
@dblock
Copy link
Collaborator

dblock commented Nov 23, 2015

What is channels_list returning here? I didn't think this was ever possible - you should record a VCR output and get a test case that reproduces the problem.

@contentfree
Copy link
Author

Don't know. Slack seems to be having intermittent issues, so maybe related (but also makes it difficult to capture/recreate). It could also be related to message throttles. Slack can return a 429 which might not have the full JSON response.

@dblock
Copy link
Collaborator

dblock commented Nov 23, 2015

In this case the library should have raised an exception (the default faraday block says so, but maybe we're not handing that error code?). Either way I don't just want to throw in "protection" for a scenario we don't understand :)

@contentfree
Copy link
Author

It does look like Faraday's own raise_error middleware should be handling anything between 400..600. Is it possible this is overwriting the mapping somehow?

@dblock
Copy link
Collaborator

dblock commented Nov 23, 2015

I don't think so, but having a recorded VCR session or a test would make things easy. Can you repro this?

@contentfree
Copy link
Author

Unable to now. It looks like Slack is back to normal and I'm unable to recreate it. But it was happening for about four hours. Weird.

@dblock
Copy link
Collaborator

dblock commented Nov 23, 2015

Slack had an outage, but I don't know what form it took :(

@dblock dblock added the bug? label Nov 23, 2015
@dblock dblock closed this as completed in 25bef46 Nov 24, 2015
@dblock
Copy link
Collaborator

dblock commented Nov 24, 2015

Fixed in dblock@25bef46. The problem was the wrong order of Faraday middleware. It should have caught the 429 error first before processing the body at all.

@contentfree
Copy link
Author

👍

@contentfree
Copy link
Author

Version bump to 0.4.1?

@dblock
Copy link
Collaborator

dblock commented Nov 24, 2015

@contentfree Still finalizing https://github.com/dblock/slack-ruby-client/pull/29 and want to make sure we don't release something broken that needs to be changed next again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants