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.

Internal server error after empty POST with XML content type

#2658

The problem appears when you try to send empty POST request to RoR app using jQuery.

jQuery.post("/users", {})

It's a bit strange in jQuery but instead of: application/x-www-form-urlencoded it adds application/xml Content-Type header. The result is 500 Internal Server Error with following backtrace:

/!\ FAILSAFE /!\  2009-05-16 23:42:27 +0200
  Status: 500 Internal Server Error
  undefined method `split' for #<Mime::Type:0x000000025200d8>
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/mime_type.rb:206:in `method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/request.rb:51:in `media_type'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/request.rb:117:in `parseable_data?'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/request.rb:138:in `POST'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/request.rb:428:in `POST'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/request.rb:381:in `parameters'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:1279:in `assign_shortcuts'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:518:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/filters.rb:606:in `process_with_filters'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/rescue.rb:65:in `call_with_exception'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:91:in `rescue in dispatch'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:97:in `dispatch'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:111:in `_call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:82:in `block in initialize'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:29:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:29:in `block in call'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:9:in `cache'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:28:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/params_parser.rb:15:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/rewindable_input.rb:25:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:93:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/reloader.rb:9:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/failsafe.rb:11:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in `block in call'
    <internal:prelude>:8:in `synchronize'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:106:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/rails/rack/static.rb:31:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `block in call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/rails/rack/log_tailer.rb:17:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call'
    /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in `service'
    /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
    /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
    /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

It's a minor issue, can be fixed in jQuery by adding data or forcing the Content-Type somehow. However it should be fixed to send a bit nicer response.

Reported by qoobaa · May 16th, 2009 @ 10:52 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. qoobaa
    qoobaa
    • Tag set to 2-3-stable, bug

    May 16th, 2009 @ 10:55 PM

  2. qoobaa
    qoobaa
    • Tag changed from 2-3-stable, bug to 2-3-stable, bug, patch, test

    Added failing test case to described problem. Test fails on Rails 2.3.2 stable, but passes on Rails edge.

    June 6th, 2009 @ 11:03 AM

  3. Ben Johnson
    Ben Johnson

    I am also getting this error, the patch listed on https://rails.lighthouseapp.com/projects/8994/tickets/2784-private-... worked fine for me.

    June 25th, 2009 @ 06:05 AM

  4. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • State changed from new to resolved

    Your test case passed in Rails 2.3.5.

    January 20th, 2010 @ 05:46 PM