-
-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails params.to_unsafe_h has side effects #799
Comments
@rpechayr Can you write out some code that shows the behavior you're describing? I'm not sure I understand your example, specifically this part:
Example: foo = ActionController::Parameters.new("foo"=>{"bar"=>["baz"]})
foo["foo"].class # ActionController::Parameters
qux = foo.to_unsafe_h
foo.object_id # 70115534341460
qux.object_id # 70115528299700
foo.class # ActionController::Parameters
foo["foo"].class # ActionController::Parameters
qux.class # ActiveSupport::HashWithIndifferentAccess |
Sure @nateberkopec ! Here is some code : foo = ActionController::Parameters.new({"param1"=>"", "elements"=>{"0"=>{"parent_id"=>"596dc5da45a800001e0012b4", "key"=>"0"}}})
foo[:elements].values.first.class #ActiveSupport::HashWithIndifferentAccess
foo.to_unsafe_h
foo[:elements].values.first.class # ActionController::Parameters Of course this example is slightly different from yours ... Honestly, I would say it's a bug in ActiveSupport itself, but I've never discovered such a thing myself :). What I am sure of is that I can see a way to tweak your documentation in order to work around this behaviour. BTW, since I wrote the original issue, I shipped the |
What Rails version are you using? On Rails 5.1.4 I get
|
Oh ! I'm using rails 4.2.7.1 |
I have same issue using Rails 5.1.6 |
The new SDK's doc doesn't encourage such usage anymore, so closing now. |
Hello, we recently migrated to sentry using this gem. We basically followed this guide here:
https://github.com/getsentry/raven-ruby/blob/master/docs/integrations/rails.rst
We then ran into a big issue when going to production. It turned out this was because calling
params.to_unsafe_h
actually mutates theparams
object, and we ended up having sub-params to beActionController::Params
instead ofActiveSupport::HashWithIndifferentAccess
. This created a big bunch ofActiveModel::ForbiddenAttributesError
in Sentry.We'll probably use
params.dup.to_unsafe_h
instead.The text was updated successfully, but these errors were encountered: