Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Debugging regression for conflicting param types

#2360

In Rails 2.1.x (and possibly 2.2.x but I don't have an app to test) if you pass conflicting parameter types like ?x=&x[y]= we get a stack trace with helpful information:

Conflicting types for parameter containers. Expected an instance of Hash but found an instance of String. This can be caused by colliding Array and Hash parameters like qs[]=value&qs[key]=value. (The parameters received were "".)

In 2.3 (and maybe 2.2) we get something much less helpful, making the problem potentially difficult to track down:

/!\ FAILSAFE /!\ 2009-03-27 Status: 500 Internal Server Error You have a nil object when you didn't expect it! The error occurred while evaluating nil.each_pair

/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/hash/indifferent_access.rb:46:in `update'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/hash/indifferent_access.rb:91:in `merge'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/request.rb:381:in `parameters'

...

Nowhere in the stack trace does it point to a line of your application's code, and nowhere is there a hint that such a pair of parameters has sneaked in. Hopefully this doesn't come up often, but given the previous existence of such a useful error message, I imagine I'm not the first person to do this and have to spend time tracking it down, so it would be nice to have this back.

Reported by trappist · March 27th, 2009 @ 03:29 PM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. krani1 (at 0x82)
    krani1 (at 0x82)

    Just to confirm I had this problem too in 2.3 and had no idea where the problem was until I read this ticket. Thank you for that!

    September 1st, 2009 @ 11:20 AM

  2. Jón Grétar Borgþórsson
    Jón Grétar Borgþórsson

    One thing to add to people who find this ticket here looking for the error.

    I got this because of a javascript price formatter. The javascript worked by taking specific input fields, hiding it, and creating a new text field with _formatted added to the end of the name.

    Thus there were 2 fields with the names: product[price] and product[price]_formatted.

    Having this will output this error. Just thought I would add this here for people googling the error. I found this problem when upgrading an app from 2.1.1 to 2.3.4.

    November 27th, 2009 @ 02:32 PM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:40 PM

  5. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:40 PM