Project

General

Profile

Actions

Bug #14689

closed

ActiveRecord::RecordInvalid: Validation failed: Name has already been taken

Added by Zach McNeilly over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Foreman Integration
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Using the salt smart proxy and salt plugin, I deleted a host from Foreman, destroyed the VM, created a new VM with the same name, and tried to use "foreman-node" to update the facts for the new host. I received the error "ActiveRecord::RecordInvalid: Validation failed: Name has already been taken" in production.log when I tried to do this.

I spoke with stbenjam on IRC and he suggested I make the following change to /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-5.0.0/app/services/foreman_salt/fact_importer.rb :

def fact_names
-@fact_names ||= fact_name_class.maximum(:id, :group => 'name')
+@fact_names ||= fact_name_class.group(:name).maximum(:id)
end

This seems to have fixed the problem for me.


Related issues 2 (0 open2 closed)

Related to Foreman - Bug #13819: Fact imports fail with: Validation failed: Fact name has already been takenClosedMarek Hulán02/20/2016Actions
Has duplicate Salt - Bug #15129: Errors in production.log when upload-salt-reports runs - katello 3.0 RC5, Foreman 1.11.2Duplicate05/23/2016Actions
Actions

Also available in: Atom PDF