undefined method `[]' for an instance of ActionDispatch::Request
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.
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 thanks for creating the issue. I'm on holiday right now and will have look at it when I get back next week.
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.
@tansengming Thank you for resolving this. I can confirm it all works with the latest version 👌🏼