Skip to content

Commit

Permalink
Skip params when unavailable (#39)
Browse files Browse the repository at this point in the history
Fixes #31.

Tracing this through, we call this [method](https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/parameters.rb#L50) and `action_dispatch.request.parameters` is nil. So we fall into this [method](https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/request.rb#L381) which eventually ends up calling this [lambda](https://github.com/rails/rails/blob/a3d54d2afe557b243d6b18f9adf119f60ffb8242/actionpack/lib/action_dispatch/http/parameters.rb#L11) which raises an error when `raw_post` is nil. 

I'm not entirely clear what [twirp](https://github.com/twitchtv/twirp-ruby) is doing to the request to end up in this state and have struggled to reproduce this in a test. This should prevent the issue though and doesn't seem to cause any other side effects that I could find.
  • Loading branch information
martin308 authored Oct 10, 2019
1 parent 64df7f3 commit 7fe276c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/honeycomb/integrations/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ def add_package_information(env)
yield "meta.package_version", ::Rails::VERSION::STRING

::ActionDispatch::Request.new(env).tap do |request|
yield "request.controller", request.params[:controller]
yield "request.action", request.params[:action]
# calling request.params will blow up if raw_post is nil
# the only known cause of this is when using the
# [twirp](https://github.com/twitchtv/twirp-ruby) rack app mounted in
# the rails app
if request.raw_post
yield "request.controller", request.params[:controller]
yield "request.action", request.params[:action]
end

break unless request.respond_to? :routes
break unless request.routes.respond_to? :router
Expand Down

0 comments on commit 7fe276c

Please sign in to comment.