tansengming / stripe-rails

A Rails Engine for integrating with Stripe
MIT License
746 stars 123 forks source link

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

Open enstyled opened 1 month ago

enstyled commented 1 month ago

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 commented 1 month ago

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

tansengming commented 1 month ago

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

4nd2in commented 2 weeks ago

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.