Project

General

Profile

Bug #16545

Host node YAML import calls AR finder with incorrect second argument

Added by Dominic Cleal about 2 years ago. Updated 2 months ago.

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

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 (diff)
Added by Dominic Cleal about 2 years 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 about 2 years ago

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

#2 Updated by Dominic Cleal about 2 years ago

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

#3 Updated by Dominic Cleal about 2 years ago

  • Legacy Backlogs Release (now unused) set to 189

Also available in: Atom PDF