Defect #9138

db:encrypt used "can't convert nil into String" "undefined method `destroy' for {}:Hash"

Added by Pierre-Louis Bonicoli about 10 years ago. Updated about 10 years ago.

Status:NewStart date:2011-08-27
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Resolution: Affected version:1.2.1

Description

Database version: sqlite3
Ruby version: ruby 1.8.7
Rails: 2.3.11
Redmine 1.2.1

Following the documentation:
  • i set the cipher key (database_cipher_key in configuration.yml)
  • i run "rake db:encrypt RAILS_ENV=production"

Login, I got this error:

Processing AccountController#login (for 57.68.62.12 at 2011-08-27 01:48:22) [POST]
  Parameters: {"back_url"=>"https%3A%2F%2Fprojects.plop.com%2F", "action"=>"login", "authenticity_token"=>"0yAZxJox+NPqwk3ccx2AfbCt88ov0OG6yJTfGeooWN4=", "user
name"=>"pierre-louis", "controller"=>"account", "password"=>"[FILTERED]", "login"=>"Login »"}

TypeError (can't convert nil into String):
  lib/redmine/ciphering.rb:46:in `key='
  lib/redmine/ciphering.rb:46:in `decrypt_text'
  lib/redmine/ciphering.rb:87:in `read_ciphered_attribute'
  app/models/auth_source.rb:38:in `account_password'
  app/models/auth_source_ldap.rb:104:in `get_user_dn'
  app/models/auth_source_ldap.rb:36:in `authenticate'
  app/models/user.rb:133:in `try_to_login'
  app/controllers/account_controller.rb:147:in `password_authentication'
  app/controllers/account_controller.rb:142:in `authenticate_user'
  app/controllers/account_controller.rb:30:in `login'
  /usr/lib/ruby/1.8/rack/head.rb:9:in `call'
  /usr/lib/ruby/1.8/rack/methodoverride.rb:24:in `call'
  /usr/lib/ruby/1.8/rack/lock.rb:11:in `call'
  /usr/lib/ruby/1.8/rack/lock.rb:11:in `synchronize'
  /usr/lib/ruby/1.8/rack/lock.rb:11:in `call'
  /usr/lib/ruby/1.8/phusion_passenger/rack/request_handler.rb:92:in `process_request'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:418:in `start_request_handler'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:358:in `handle_spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/utils.rb:184:in `safe_fork'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:354:in `handle_spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `__send__'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `main_loop'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:163:in `start'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:213:in `start'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `__send__'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `main_loop'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
  /usr/lib/phusion_passenger/passenger-spawn-server:61

i run following commands:

  • rake db:decrypt RAILS_ENV=production
  • touch tmp/restart.txt
  • set a simpler value (alphanumeric) for the cipher key
  • rake db:encrypt RAILS_ENV=production
  • touch tmp/restart.txt

At this times the error was gone.
I check in the database: the account_password field of auth_source table was encrypted.
Modifying again the value of the key (with the first value used) don't trigger the error

Then few hours after I got this error:

Processing AccountController#login (for 57.68.62.12 at 2011-08-27 16:20:33) [POST]
  Parameters: {"back_url"=>"https%3A%2F%2Fprojects.plop.com%2F", "action"=>"login", "authenticity_token"=>"mu79e6EjFrTSJuTzUCXOgeL6GLMJIyJm7fi1zKcD4hk=", "use
name"=>"pierre-louis", "controller"=>"account", "password"=>"[FILTERED]", "login"=>"Login »"}

NoMethodError (undefined method `destroy' for {}:Hash):
  app/controllers/application_controller.rb:92:in `logged_user='
  app/controllers/account_controller.rb:203:in `successful_authentication'
  app/controllers/account_controller.rb:155:in `password_authentication'
  app/controllers/account_controller.rb:142:in `authenticate_user'
  app/controllers/account_controller.rb:30:in `login'
  /usr/lib/ruby/1.8/rack/head.rb:9:in `call'
  /usr/lib/ruby/1.8/rack/methodoverride.rb:24:in `call'
  /usr/lib/ruby/1.8/rack/lock.rb:11:in `call'
  /usr/lib/ruby/1.8/rack/lock.rb:11:in `synchronize'
  /usr/lib/ruby/1.8/rack/lock.rb:11:in `call'
  /usr/lib/ruby/1.8/phusion_passenger/rack/request_handler.rb:92:in `process_request'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:418:in `start_request_handler'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:358:in `handle_spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/utils.rb:184:in `safe_fork'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:354:in `handle_spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `__send__'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `main_loop'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:163:in `start'
  /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:213:in `start'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `__send__'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `main_loop'
  /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
  /usr/lib/phusion_passenger/passenger-spawn-server:61

History

#1 Updated by Etienne Massip about 10 years ago

About the second error, check #7857.

#2 Updated by Pierre-Louis Bonicoli about 10 years ago

Thanks, second error is probably same problem as #7857. If the second error persist, I will update #7857.

Also available in: Atom PDF