Validation failed: Name has already been taken, when registering a client

For some reason, the search didn’t find any host with these ids (the result was [] which means empty array). Let’s try this first

foreman-rake console
host = Host.find(233)
host.destroy
exit

Recently I’ve seen people reporting having host records using the wrong type. That could explain it. Try also this

# sudo -u postgres psql foreman -c 'select id, name, type, organization_id, location_id from hosts;'

If you’ll see Host::Base in the resulting table, it explains everyting. In such case, this should work

foreman-rake console
Host::Base.where(id: [233, 265, 274]).destroy_all
exit

potentially it could fail with another error on deletion, that’s being discussed at Reports Processing Failure (AssociationTypeMismatch) - #12 by Marek_Hulan