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.

reset_session causes rack exception if session blank

#2108

I had a controller action in 2.2.2 which contained "reset_session":


def destroy
  reset_session
end

Now in 2.3.0 RC1 that line bails with a lengthy stack trace:


/!\ FAILSAFE /!\  Sun Mar 01 20:35:31 +0100 2009
  Status: 500 Internal Server Error
  You have a nil object when you didn't expect it!
The error occurred while evaluating nil.data=
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/activerecord/lib/active_record/session_store.rb:300:in `set_session'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/activerecord/lib/active_record/base.rb:1454:in `silence'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/activerecord/lib/active_record/session_store.rb:298:in `set_session'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb:116:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/failsafe.rb:11:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/rack_ext/lock.rb:15:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/rack_ext/lock.rb:15:in `synchronize'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/rack_ext/lock.rb:15:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:83:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/railties/lib/rails/rack/static.rb:27:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
    /Library/Ruby/Gems/1.8/gems/rack-0.9.1/lib/rack/handler/mongrel.rb:59:in `process'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:159:in `process_client'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `each'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `process_client'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `initialize'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `new'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `initialize'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `new'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `run'
    /Library/Ruby/Gems/1.8/gems/rack-0.9.1/lib/rack/handler/mongrel.rb:32:in `run'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/railties/lib/commands/server.rb:100
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    script/server:3

Workaround is:


def destroy
  reset_session unless session.blank?
end

Currently trying to come up with a minimal test case to reproduce.

Reported by Wincent Colaiuta · March 1st, 2009 @ 07:59 PM

State: resolved
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. Wincent Colaiuta
    Wincent Colaiuta

    Ok, here are the repro instructions:

    Create a new app:

    
    rails ticket2108
    cd ticket2108
    

    Create a demo scaffold:

    
    script/generate scaffold Yadda
    

    Turn on ActiveRecord session store by uncommenting this line in config/initializers/session_store.rb:

    
    # ActionController::Base.session_store = :active_record_store
    

    Insert "reset_session" in a controller action; for example, in app/controllers/yaddas_controller.rb:

    
      def index
        reset_session
        # ... etc
    

    Fire up the server:

    
    script/server
    

    Now visit http://localhost:3000/yaddas and watch things go boom.

    March 1st, 2009 @ 08:09 PM

  2. josh
    josh
    • Assigned user set to josh

    March 2nd, 2009 @ 01:39 AM

  3. josh
    josh
    • Milestone cleared.

    March 3rd, 2009 @ 06:35 PM

  4. Repository
    Repository
    • State changed from new to resolved

    (from [9b1b88f09cf1498f04e1cd469d0d5ffccf2b93cc]) Fixed reset_session for ActiveRecord session store [#2108 reset_session causes rack exception if session blank state:resolved] http://github.com/rails/rails/co...

    March 3rd, 2009 @ 07:07 PM

  5. Wincent Colaiuta