Bug #16545

Host node YAML import calls AR finder with incorrect second argument

Added by Dominic Cleal 7 months ago. Updated 7 months ago.

Status:Closed
Priority:Normal
Assigned To:Dominic Cleal
Category:Rails
Target version:-
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/3842
Story points-
Velocity based estimate-
Release1.14.0Release relationshipAuto

Description

Under Rails 5, the Host::Managed#importNode method raises an error when importing a YAML file that contains parameterised classes (as in our unit test):

HostTest::location or organizations are not enabled.test_0013_should import from external nodes output
TypeError: can't quote Hash
    app/models/host/managed.rb:489:in `block in importNode'
    app/models/host/managed.rb:488:in `each'
    app/models/host/managed.rb:488:in `importNode'
    test/unit/host_test.rb:757:in `block (2 levels) in <class:HostTest>' (TypeError)
/usr/local/rvm/gems/ruby-2.3.0@test_develop_pr_core-2/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/quoting.rb:177

On Rails 4, calling Puppetclass.find_by_name(["klass", {:params => foo}]) was just returning the klass and ignoring the second element of the array. Under Rails 5 it raises an error.

The .find_by_name call should only be passed a string with a name.

Note that the classes in an ENC YAML may be either an array or hash, but the unit test only checks the hash format.

Associated revisions

Revision 37c0b37f
Added by Dominic Cleal 7 months ago

fixes #16545 - correctly search for classes from YAML import

Prevents a full class hash of name => parameters being passed to the AR
finder when using a parameterized (hash-style) YAML format.

History

#1 Updated by The Foreman Bot 7 months ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3842 added

#2 Updated by Dominic Cleal 7 months ago

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

#3 Updated by Dominic Cleal 7 months ago

  • Release set to 1.14.0

Also available in: Atom PDF