integrallis / stripe_event

Stripe webhook integration for Rails applications.
https://rubygems.org/gems/stripe_event
MIT License
841 stars 107 forks source link

ArgumentError - wrong number of arguments (2 for 5): #19

Closed bokmann closed 11 years ago

bokmann commented 11 years ago

I'm not doing anything fancy yet, and in fact I've removed all my event subscriptions to confirm this still happens. I've tried it with the latest version of the gem as well as master, and also tried it turning off the event_retriever.

Any event I receive, for instance the attached log is from creating a plan from the test console, results in the above error. attached is the rails event and corresponding stack trace. I'm using Rails 3.2.13 and a handful of non-controvertial gems.

Any ideas?

Started POST "/api/stripe" for 127.0.0.1 at 2013-06-16 15:10:29 -0400 Processing by StripeEvent::WebhookController#event as XML Parameters: {"id"=>"evt_21pCFyxFerySHp", "created"=>1371409822, "livemode"=>false, "type"=>"plan.created", "data"=>{"object"=>{"interval"=>"month", "name"=>"1", "amount"=>999, "currency"=>"usd", "id"=>"1", "object"=>"plan", "livemode"=>false, "interval_count"=>1, "trial_period_days"=>30}}, "object"=>"event", "pending_webhooks"=>1, "request"=>"iar_21pChQ3qdCyUBS", "webhook"=>{"id"=>"evt_21pCFyxFerySHp", "created"=>1371409822, "livemode"=>false, "type"=>"plan.created", "data"=>{"object"=>{"interval"=>"month", "name"=>"1", "amount"=>999, "currency"=>"usd", "id"=>"1", "object"=>"plan", "livemode"=>false, "interval_count"=>1, "trial_period_days"=>30}}, "object"=>"event", "pending_webhooks"=>1, "request"=>"iar_21pChQ3qdCyUBS"}} Completed 500 Internal Server Error in 1ms

ArgumentError - wrong number of arguments (2 for 5): (gem) meta_request-0.2.5/lib/meta_request/railtie.rb:19:in block (2 levels) in <class:Railtie>' (gem) activesupport-3.2.13/lib/active_support/notifications/fanout.rb:47:inpublish' (gem) activesupport-3.2.13/lib/active_support/notifications/fanout.rb:25:in block in publish' (gem) activesupport-3.2.13/lib/active_support/notifications/fanout.rb:25:inpublish' (gem) activesupport-3.2.13/lib/active_support/notifications.rb:118:in publish' /Users/dbock/clients/codesherpas/tracking_papers/vendor/bundle/ruby/1.9.1/bundler/gems/stripe_event-590f4ca55acb/lib/stripe_event.rb:19:inpublish' /Users/dbock/clients/codesherpas/tracking_papers/vendor/bundle/ruby/1.9.1/bundler/gems/stripe_event-590f4ca55acb/lib/stripe_event.rb:15:in instrument' /Users/dbock/clients/codesherpas/tracking_papers/vendor/bundle/ruby/1.9.1/bundler/gems/stripe_event-590f4ca55acb/app/controllers/stripe_event/webhook_controller.rb:4:inevent' (gem) actionpack-3.2.13/lib/action_controller/metal/implicit_render.rb:4:in send_action' (gem) actionpack-3.2.13/lib/abstract_controller/base.rb:167:inprocess_action' (gem) actionpack-3.2.13/lib/action_controller/metal/rendering.rb:10:in process_action' (gem) actionpack-3.2.13/lib/abstract_controller/callbacks.rb:18:inblock in process_action' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:403:in _run__3447592120788238416__process_action__138177565787492261__callbacks' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:inrun_callback' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:385:in _run_process_action_callbacks' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:81:inrun_callbacks' (gem) actionpack-3.2.13/lib/abstract_controller/callbacks.rb:17:in process_action' (gem) actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:inprocess_action' (gem) actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in block in process_action' (gem) activesupport-3.2.13/lib/active_support/notifications.rb:123:inblock in instrument' (gem) activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in instrument' (gem) activesupport-3.2.13/lib/active_support/notifications.rb:123:ininstrument' (gem) actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in process_action' (gem) actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:inprocess_action' (gem) activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:18:in process_action' (gem) actionpack-3.2.13/lib/abstract_controller/base.rb:121:inprocess' (gem) actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in process' (gem) actionpack-3.2.13/lib/action_controller/metal.rb:203:indispatch' (gem) actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in dispatch' (gem) actionpack-3.2.13/lib/action_controller/metal.rb:246:inblock in action' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in dispatch' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:incall' (gem) journey-1.0.4/lib/journey/router.rb:68:in block in call' (gem) journey-1.0.4/lib/journey/router.rb:56:incall' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in call' (gem) railties-3.2.13/lib/rails/engine.rb:479:incall' (gem) railties-3.2.13/lib/rails/railtie/configurable.rb:30:in method_missing' (gem) journey-1.0.4/lib/journey/router.rb:68:inblock in call' (gem) journey-1.0.4/lib/journey/router.rb:56:in call' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:incall' (gem) meta_request-0.2.5/lib/meta_request/middlewares/app_request_handler.rb:11:in call' (gem) rack-contrib-1.1.0/lib/rack/contrib/response_headers.rb:17:incall' (gem) meta_request-0.2.5/lib/meta_request/middlewares/headers.rb:16:in call' (gem) meta_request-0.2.5/lib/meta_request/middlewares/meta_request_handler.rb:13:incall' (gem) warden-1.2.1/lib/warden/manager.rb:35:in block in call' (gem) warden-1.2.1/lib/warden/manager.rb:34:incall' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in call' (gem) rack-1.4.5/lib/rack/etag.rb:23:incall' (gem) rack-1.4.5/lib/rack/conditionalget.rb:35:in call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:incall' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:incall' (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in context' (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:incall' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in call' (gem) activerecord-3.2.13/lib/active_record/query_cache.rb:64:incall' (gem) activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:inblock in call' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in _run__1631969465490691919__call__3364289358493390362__callbacks' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:inrun_callback' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:385:in _run_call_callbacks' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:81:inrun_callbacks' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:65:incall' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in call' (gem) better_errors-0.7.2/lib/better_errors/middleware.rb:84:inprotected_app_call' (gem) better_errors-0.7.2/lib/better_errors/middleware.rb:79:in better_errors_call' (gem) better_errors-0.7.2/lib/better_errors/middleware.rb:56:incall' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:incall' (gem) railties-3.2.13/lib/rails/rack/logger.rb:32:in call_app' (gem) railties-3.2.13/lib/rails/rack/logger.rb:16:inblock in call' (gem) activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in tagged' (gem) railties-3.2.13/lib/rails/rack/logger.rb:16:incall' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in call' (gem) rack-1.4.5/lib/rack/methodoverride.rb:21:incall' (gem) rack-1.4.5/lib/rack/runtime.rb:17:in call' (gem) activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:incall' (gem) rack-1.4.5/lib/rack/lock.rb:15:in call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:incall' (gem) railties-3.2.13/lib/rails/engine.rb:479:in call' (gem) railties-3.2.13/lib/rails/application.rb:223:incall' (gem) rack-1.4.5/lib/rack/content_length.rb:14:in call' (gem) railties-3.2.13/lib/rails/rack/log_tailer.rb:17:incall' (gem) rack-1.4.5/lib/rack/handler/webrick.rb:59:in service' /Users/dbock/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/webrick/httpserver.rb:111:inservice' /Users/dbock/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/webrick/httpserver.rb:70:in run' /Users/dbock/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/webrick/server.rb:183:inblock in start_thread'

bokmann commented 11 years ago

I dove into this issue a little more, and I'm not sure which of two projects to try to contribute a fix to. The actual exception is thrown in the gem meta_request... on line 19 of their railties file they assume that they can subscribe to all notifications, take the supplied attributes, and create an ActiveSupport::Notification from them. I'm not sure this is a reasonable assumption or not.

In your stripe_event.rb file you publish a notification with just two values, the name, and the stripe event data. When these two values land in meta_request, your two values are passed to the 5 for ActiveSupport::Notification.new, and we get the 2 for 5 error.

The solution is either to have meta_request not assume it can create an ActiveSupport::Event, or have your gem use an ActiveSupport::Notifications::Event class instead of your own custom event.

Looking futher with a goal of giving one of the two of you a pullup request.

invisiblefunnel commented 11 years ago

Thanks for posting this issue. I'm traveling today but will take a look as soon as I can.

Sent from my iPhone

On Jun 16, 2013, at 14:13, David Bock notifications@github.com wrote:

I dove into this issue a little more, and I'm not sure which of two projects to try to contribute a fix to. The actual exception is thrown in the gem meta_request... on line 19 of their railties file they assume that they can subscribe to all notifications, take the supplied attributes, and create an ActiveSupport::Notification from them. I'm not sure this is a reasonable assumption or not.

In your stripe_event.rb file you publish a notification with just two values, the name, and the stripe event data. When these two values land in meta_request, your two values are passed to the 5 for ActiveSupport::Notification.new, and we get the 2 for 5 error.

The solution is either to have meta_request not assume it can create an ActiveSupport::Event, or have your gem use an ActiveSupport::Notifications::Event class instead of your own custom event.

Looking futher with a goal of giving one of the two of you a pullup request.

— Reply to this email directly or view it on GitHub.

invisiblefunnel commented 11 years ago

AS::Notifications provides two methods (with differing arities) for broadcasting events to listeners so you are correct that the assumption made in meta_request does not hold in all cases. That said, AS::Notifications.publish is not well documented so it doesn't get used very often. In previous versions, stripe_event used AS::Notifications.instrument, but the extra arguments were thrown away so I switched to publish.

I think your issue on meta_request addresses the problem well, but I'm open to suggestions for solving the problem on my end. Thanks again for posting.

invisiblefunnel commented 11 years ago

According to the maintainer, this issue should be fixed by meta_request 0.2.7: https://github.com/dejan/rails_panel/issues/61#issuecomment-19877221.