stripe-rails icon indicating copy to clipboard operation
stripe-rails copied to clipboard

undefined method `[]' for an instance of ActionDispatch::Request

Open enstyled opened this issue 1 year ago • 2 comments

Started getting this error after updating to Rails 7.1.3.4. It was bundled with other bundle update changes so it might also be another dependency.

undefined method `[]' for an instance of ActionDispatch::Request

From AppSignal:

Backtrace: stripe-rails (2.5.0) app/models/stripe/event_dispatch.rb:11:in `retrieve_stripe_event'

Once reverted to a version before the bundle update and retried the webhook, it all worked as before.

enstyled avatar Jun 14 '24 18:06 enstyled

After further investigation, found out it's not the Rails version update that caused this, but the update of Rack from 3.0 to 3.1

enstyled avatar Jun 16 '24 12:06 enstyled

@enstyled thanks for creating the issue. I'm on holiday right now and will have look at it when I get back next week.

tansengming avatar Jun 20 '24 17:06 tansengming

I am having the same error message (also rack 3.1) in the Stripe::EventDispatch::retrieve_stripe_event method. The problematic code is the line id = request['id'].

Property access syntax for parameters is not possible for ActionDispatch::Request anymore in rack version 3.1:

Request#[] is deprecated and will be removed in a future version of Rack. Please use request.params[] instead

For testing purposes I changed the code to request.params[:id] locally and I could retrieve the id I needed to do Stripe::Event.retrieve(id).

As for now, I need to use version 3.0 of rack until a fix for newer rack versions is released.

4nd2in avatar Jul 04 '24 10:07 4nd2in

@tansengming Thank you for resolving this. I can confirm it all works with the latest version 👌🏼

enstyled avatar Aug 13 '24 15:08 enstyled