Skip to content

Rails 6.1 bug involving params with a nested param named param #68

@sholden

Description

@sholden

When calling get :action, params: { params: 'string' }, RouteSet#url_for is trying to merge! the inner params string into the params hash.

https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/routing/route_set.rb#L826

I added a failing test here:

https://github.com/sholden/rails-controller-testing/blob/bug/merge-nested-params/test/controllers/template_assertions_test.rb#L190

The issue came up while migrating to 6.1, looking into writing a failing spec directly in rails/rails, rather than through controller testing, but this one helped pinpoint the issue as it showed up in our code.

We could change RouteSet to check if options.key?(:params) && options[:params].is_a?(Hash) before attempting a merge, but maybe there's a better way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions