This project is archived and is in readonly mode.

#1668 ✓resolved
Bence Nagy

'use ActionController::VerbPiggybacking' brakes multipart forms with Passenger

Reported by Bence Nagy | December 30th, 2008 @ 01:30 AM

Rails does not handle multipart forms unless I disable 'use ActionController::VerbPiggybacking' in middlewares.rb. Platform: Ubuntu 8.10 with the latest REE, Passenger 2.0.6 and 2.1.0 (Edge).

/!\ FAILSAFE /!\ 2008. december 30., 01:37 Status: 500 Internal Server Error no content body

/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/request_parser.rb:225:in `read_multipart'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/request_parser.rb:153:in `parse_multipart_form_parameters'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/request_parser.rb:67:in `parse_formatted_request_parameters'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/request_parser.rb:8:in `request_parameters'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/request.rb:438:in `request_parameters'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/request.rb:397:in `parameters'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/base.rb:1221:in `assign_shortcuts'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/base.rb:521:in `process_without_filters'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `sass_old_process'
/opt/ruby-enterprise-1.8.6-20081215/lib/ruby/gems/1.8/gems/haml-2.0.6/rails/../lib/sass/plugin/rails.rb:19:in `process'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/rescue.rb:65:in `call_with_exception'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:66:in `dispatch'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:86:in `_call'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:57:in `initialize'
/home/nagybence/dev/moly/vendor/rails/railties/lib/rails/rack/metal.rb:32:in `call'
/home/nagybence/dev/moly/vendor/rails/railties/lib/rails/rack/metal.rb:32:in `call'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/verb_piggybacking.rb:21:in `call'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:95:in `call'
/home/nagybence/dev/moly/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `call'
/home/nagybence/dev/moly/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/home/nagybence/dev/moly/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
/home/nagybence/dev/moly/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/failsafe.rb:11:in `call'
/home/nagybence/dev/moly/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:81:in `call'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/rack/request_handler.rb:65:in `process_request'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_request_handler.rb:204:in `main_loop'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/railz/application_spawner.rb:331:in `start_request_handler'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/railz/application_spawner.rb:294:in `handle_spawn_application'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/utils.rb:180:in `safe_fork'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/railz/application_spawner.rb:292:in `handle_spawn_application'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server.rb:332:in `__send__'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server.rb:332:in `main_loop'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server.rb:182:in `start_synchronously'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server.rb:149:in `start'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/railz/application_spawner.rb:187:in `start'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/spawn_manager.rb:260:in `spawn_rails_application'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server_collection.rb:121:in `lookup_or_add'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/spawn_manager.rb:254:in `spawn_rails_application'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server_collection.rb:75:in `synchronize'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server_collection.rb:74:in `synchronize'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/spawn_manager.rb:253:in `spawn_rails_application'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/spawn_manager.rb:148:in `spawn_application'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/spawn_manager.rb:285:in `handle_spawn_application'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server.rb:332:in `__send__'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server.rb:332:in `main_loop'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/lib/passenger/abstract_server.rb:182:in `start_synchronously'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.1.0/bin/passenger-spawn-server:46

Comments and changes to this ticket

  • josh

    josh December 30th, 2008 @ 03:48 AM

    • Milestone cleared.
    • State changed from “new” to “open”
    • Assigned user set to “josh”

    This is a critical bug and I want to get it fixed ASAP. I just need a little bit more information. Is there anyway you can put together a unit test case?

  • Bence Nagy

    Bence Nagy December 30th, 2008 @ 09:59 AM

    Sorry I can not say more closer. It works if I delete 'req.parameters[:_method]' in verb_piggybacking.rb (line: #13), so it fails at Request.parameters. And I do not know how to write and run a test under Passenger...

  • Suave Su

    Suave Su December 31st, 2008 @ 08:07 AM

    I met the same issue with rails edge & passenger, but work very well under mongrel at my localhost

  • josh

    josh January 3rd, 2009 @ 12:46 AM

    • Tag changed from passenger to multipart, rack

    Added a test to prove this bug: http://github.com/rails/rails/co...

    I still don't have a solid fix yet.

  • Florian Aßmann

    Florian Aßmann January 4th, 2009 @ 11:41 AM

    I assume the Body got read once and since it's an UnixSocket on some systems this renders the whole POST body invalid (no .rewind) when ActionController tries to dispatch.

    
        /Users/florian/dev/farmfacts/vendor/rails/actionpack/lib/action_controller/request_parser.rb:303:in `read_multipart'
        /Users/florian/dev/farmfacts/vendor/rails/actionpack/lib/action_controller/request_parser.rb:153:in `parse_multipart_form_parameters'
        /Users/florian/dev/farmfacts/vendor/rails/actionpack/lib/action_controller/request_parser.rb:67:in `parse_formatted_request_parameters'
        /Users/florian/dev/farmfacts/vendor/rails/actionpack/lib/action_controller/request_parser.rb:8:in `request_parameters'
        /Users/florian/dev/farmfacts/vendor/rails/actionpack/lib/action_controller/request.rb:438:in `request_parameters'
        /Users/florian/dev/farmfacts/vendor/rails/actionpack/lib/action_controller/request.rb:397:in `parameters'
        /Users/florian/dev/farmfacts/vendor/rails/actionpack/lib/action_controller/verb_piggybacking.rb:15:in `call'
    
  • Florian Aßmann

    Florian Aßmann January 4th, 2009 @ 12:21 PM

    I got a MethodNotAllowed from ActionController::Routing::RouteSet[64] so I learning some more Rails internals where I found something far away from VerbPiggybacking.

    polymorphic_path currently generates wrong paths, imho:

    create_path = polymorphic_path [:admin, record, record.attachments.new]

    Before: /admin/articles/2/attachments

    After: /admin/articles/2

    Well, when an exception is raised at this point the @env got lost somehow in ActionController::Dispatcher[66] and I must correct my habit to first look into the log where, in this case, no information about the requested url can be found, but to look in the browser address bar.

    Now I'll try to get @env inplace...

  • Florian Aßmann

    Florian Aßmann January 4th, 2009 @ 12:50 PM

    Ok, I extended the global rescue hack to get the response back in place.

  • Florian Aßmann

    Florian Aßmann January 4th, 2009 @ 01:13 PM

    polymorphic_path works correctly

  • Florian Aßmann

    Florian Aßmann January 4th, 2009 @ 03:49 PM

    The problem with the already read body still exists:

    
    /!\ FAILSAFE /!\  Sun Jan 04 16:24:33 +0100 2009
      Status: 500 Internal Server Error
      no content body
        /var/www/vendor/rails/actionpack/lib/action_controller/request_parser.rb:225:in `read_multipart'
        /var/www/vendor/rails/actionpack/lib/action_controller/request_parser.rb:153:in `parse_multipart_form_parameters'
        /var/www/vendor/rails/actionpack/lib/action_controller/request_parser.rb:67:in `parse_formatted_request_parameters'
        /var/www/vendor/rails/actionpack/lib/action_controller/request_parser.rb:8:in `request_parameters'
        /var/www/vendor/rails/actionpack/lib/action_controller/request.rb:438:in `request_parameters'
        /var/www/vendor/rails/actionpack/lib/action_controller/request.rb:397:in `parameters'
        /var/www/vendor/rails/actionpack/lib/action_controller/base.rb:1221:in `assign_shortcuts'
        /var/www/vendor/rails/actionpack/lib/action_controller/base.rb:521:in `process_without_filters'
        /var/www/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `sass_old_process'
        /var/www/vendor/gems/haml-2.0.6/rails/../lib/sass/plugin/rails.rb:19:in `process'
        /var/www/vendor/rails/actionpack/lib/action_controller/rescue.rb:65:in `call_with_exception'
        /var/www/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:66:in `dispatch'
        /var/www/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:86:in `_call'
        /var/www/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:57:in `initialize'
        /var/www/vendor/rails/railties/lib/rails/rack/metal.rb:32:in `call'
        /var/www/vendor/rails/railties/lib/rails/rack/metal.rb:32:in `call'
        /var/www/vendor/rails/actionpack/lib/action_controller/verb_piggybacking.rb:21:in `call'
    
  • Repository

    Repository January 4th, 2009 @ 06:13 PM

    • State changed from “open” to “resolved”

    (from [f00e86d7e9c7a4689a49fc085bcb757c5a2c0b03]) Memoize request accessors on the Rack env so other request objects have access to the same cache [#1668 state:resolved] http://github.com/rails/rails/co...

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages