Project

General

Profile

Bug #10803

NoMethodError: undefined method `constantize' for nil:NilClass throughout db:seed log

Added by Eric Helms about 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DB migrations
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

2015-06-12 13:55:58 [app] [W] unknown class , ignoring
 | NoMethodError: undefined method `constantize' for nil:NilClass
 | /home/vagrant/foreman/app/models/filter.rb:66:in `get_resource_class'
 | /home/vagrant/foreman/app/models/filter.rb:90:in `resource_class'
 | /home/vagrant/foreman/app/models/filter.rb:97:in `granular?'
 | /home/vagrant/foreman/app/models/filter.rb:131:in `build_taxonomy_search'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:418:in `_run__1604840531046015080__validation__382041520694395799__callbacks'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:405:in `__run_callback'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:385:in `_run_validation_callbacks'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:81:in `run_callbacks'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activemodel-3.2.21/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activemodel-3.2.21/lib/active_model/validations.rb:195:in `valid?'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/validations.rb:69:in `valid?'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/validations.rb:77:in `perform_validations'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/validations.rb:56:in `save!'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/transactions.rb:264:in `block in save!'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/transactions.rb:208:in `transaction'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
 | /home/vagrant/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.21/lib/active_record/transactions.rb:264:in `save!'
 | /home/vagrant/foreman/db/seeds.rb:35:in `block in create_filters'
 | /home/vagrant/foreman/db/seeds.rb:26:in `each'
 | /home/vagrant/foreman/db/seeds.rb:26:in `create_filters'
 | /home/vagrant/foreman/db/seeds.rb:47:in `create_role'

Associated revisions

Revision 75e3743d (diff)
Added by Eric Helms about 4 years ago

Fixes #10803: Return nil if no resource_type when creating a filter.

In some instances, such as during DB seed, when a filter is being
created for the first time the before_validation callback to
build_taxonomy_search is triggered. Since, the filter hasn't been
saved, there are no permissions connected to the filter yet when
the 'permissions.first.try(:resource_type)' call is made generating
the resource_type. This in turn leads get_resource_class to call
constantize on 'nil' and throw an exception which then appears
throughout the db:seed log.

History

#1 Updated by The Foreman Bot about 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2456 added
  • Pull request deleted ()

#2 Updated by Eric Helms about 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by Dominic Cleal about 4 years ago

  • Category set to DB migrations
  • Assignee set to Eric Helms
  • Legacy Backlogs Release (now unused) set to 63

Also available in: Atom PDF