Project

General

Profile

Actions

Bug #24069

open

Organization is not a subclass of Taxonomy

Added by Stephen Benjamin almost 6 years ago. Updated almost 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Rails
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Foreman with Katello is sometimes returning the error "Invalid single-table inheritance type: Organization is not a subclass of Taxonomy." It now happens almost every other hammer command for me on a dev environment. It has to do with Rails' DescendantTracker losing descendants of Taxonomy. I don't know what it means yet, but probably something with rails autoloading and Katello's taxonomy extensions.

From: /home/vagrant/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/inheritance.rb @ line 203 ActiveRecord::Inheritance::ClassMethods#find_sti_class:

    187: def find_sti_class(type_name)
    188:   type_name = base_class.type_for_attribute(inheritance_column).cast(type_name)
    189:   subclass = begin
    190:     if store_full_sti_class
    191:       ActiveSupport::Dependencies.constantize(type_name)
    192:     else
    193:       compute_type(type_name)
    194:     end
    195:   rescue NameError
    196:     raise SubclassNotFound,
    197:       "The single-table inheritance mechanism failed to locate the subclass: '#{type_name}'. " \
    198:       "This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " \
    199:       "Please rename this column if you didn't intend it to be used for storing the inheritance class " \
    200:       "or overwrite #{name}.inheritance_column to use another column for that information." 
    201:   end
    202:   unless subclass == self || descendants.include?(subclass)
 => 203:     require 'pry-remote'; binding.remote_pry
    204:     raise SubclassNotFound, "Invalid single-table inheritance type: #{subclass.name} is not a subclass of #{name}" 
    205:   end
    206:   subclass
    207: end

[1] pry(Taxonomy)> self
=> Taxonomy(id: integer, name: string, type: string, created_at: datetime, updated_at: datetime, ignore_types: text, description: text, label: string, ancestry: string, title: string, manifest_refreshed_at: datetime)
[2] pry(Taxonomy)> desendants
NameError: undefined local variable or method `desendants' for #<Class:0x0000000a4afce0>
Did you mean?  descendants
from /home/vagrant/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.6/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
[3] pry(Taxonomy)> descendants
=> []
[4] pry(Taxonomy)> method(:descendants).source_location
=> ["/home/vagrant/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/descendants_tracker.rb",
 56]
[5] pry(Taxonomy)> ActiveSupport::DescendantsTracker.descendants
ArgumentError: wrong number of arguments (given 0, expected 1)
from /home/vagrant/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/descendants_tracker.rb:12:in `descendants'
[6] pry(Taxonomy)> ActiveSupport::DescendantsTracker.descendants(self)
=> []
[7] pry(Taxonomy)> Taxonomy.descendants
=> [Location(id: integer, name: string, type: string, created_at: datetime, updated_at: datetime, ignore_types: text, description: text, label: string, ancestry: string, title: string, manifest_refreshed_at: datetime),
 Organization(id: integer, name: string, type: string, created_at: datetime, updated_at: datetime, ignore_types: text, description: text, label: string, ancestry: string, title: string, manifest_refreshed_at: datetime)]
Actions #1

Updated by Stephen Benjamin almost 6 years ago

  • Project changed from Katello to Foreman
  • Category set to Rails
  • Triaged set to No

Moving to Foreman as we've now seen it with plain Foreman and other plugins than Katello.

Actions #2

Updated by Marek Hulán almost 6 years ago

Quick workaround, restart your develop server. This error only occures after some code change, seems the class is linked somewhere before the rails env is fully loaded.

Actions #3

Updated by Daniel Lobato Garcia almost 6 years ago

I'm also getting this error when developing a new feature in foreman_ansible, it goes away after a Rails restart as Marek said

Actions #4

Updated by Stephen Benjamin almost 6 years ago

I have seen this even without any code changing, e.g. multiple hammer commands against Katello without editing any file, the second or third one fails with this error.

There are also reports in production installs on Satellite, e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1596645. Rex fixed this in #27074, although maybe theirs is a separat eissue.

Actions

Also available in: Atom PDF